RE: How to Auto fill fields on Save in Django Admin?

2011-02-16 Thread Chris Matthews
Hi Matteius,

You must set blank=True in the model so that the form can be returned to you 
with those fields empty and then you fill it in the save().

pub_date = models.DateTimeField(blank=True)
author = models.ForeignKey(User, blank=True, verbose_name='Author')

Also read up on editable=False

Regards
Chris
-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Matteius
Sent: 17 February 2011 08:47
To: Django users
Subject: How to Auto fill fields on Save in Django Admin?

I have an Announcement model that has two fields I want to auto-fill
in when they are left blank (they are required fields with normal
defaults).  I have the following Code (simplified data listing for
this post)  THe Problem is that when I go to save an Announement
in the admin with either of those fields blank it returns to the Add/
Edit Form with "This field is required." despite my code to try and
fill that in.  Clearly I'm missing how to do this, any advice?

class Announcement(models.Model):
""" Represents an Announcement in the classcomm system. """

# Data Model Fields
pub_date = models.DateTimeField()
author = models.ForeignKey(User, verbose_name='Author')

def clean(self):
""" Implement auto fill pub_date. """
if not self.pub_date:
self.pub_date = datetime.today()
super(Announcement, self).clean()
# EndDef

def save(self):
""" Implement auto fill pub_date. """
if not self.pub_date:
self.pub_date = datetime.today()
super(Announcement, self).save()
# EndDef
# EndClass

Then in admin.py I have:

class AnnouncementAdmin(admin.ModelAdmin):
""" Admin customizations for Announcement Models. """
fieldsets = (
(None, {
'fields': ('headline', 'department', 'course', 'content')
}),
('Advanced options', {
'classes': ('collapse',),
'fields': ('author', 'pub_date', 'make_global')
}),
)

def save_model(self, request, obj, form, change):
""" Autofill in author when blank on save models. """
obj.author = request.user
obj.save()
# EndDef

def save_formset(self, request, form, formset, change):
""" Autofill in author when blank on save formsets. """
instances = formset.save(commit=False)
for instance in instances:
instance.author = request.user
instance.save()
formset.save_m2m()
# EndDef
# EndClass


Regards,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: how can I filter related (foreign key) objects?

2011-02-16 Thread Chris Matthews
Hi Serek,



Try this

def doMagic(self):

date = '2010-05-04'

#//here I need to take 10 conencted Bbb objects whcich data is less 
then date

previous10days = Bbb.objects.filter(date__lt=date).order_by('data')



Also read up about managers 
http://docs.djangoproject.com/en/1.2/topics/db/managers/ in case you should 
consider using it (depending upon how much magic is required from your 
function).



Regards

Chris



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of serek
Sent: 17 February 2011 00:51
To: Django users
Subject: how can I filter related (foreign key) objects?



Hi



I have not idea how to describe my problem, so I show pice of code:





class Aaa(models.Model):

name = models.CharField(max_length=200, unique=True)

is_active = models.BooleanField()



class Meta:

ordering = ('name',)



def doMagic(self):

  date = '2010-05-04'

  //here I need to take 10 conencted Bbb objects whcich data is less

then date

previous10days = self.bbb_set.filter(Bbb.date <

date).order_by('data')





class Bbb(models.Model):

date = models.DateField()

value = models.DecimalField(max_digits=7, decimal_places=2)

aaa = models.ForeignKey(Aaa)



a = Aaa()

a.doMagic throw error that Bbb.date is undefined - what can be wrong?



--

You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.

To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.

For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: form select box how to (help needed)

2011-02-16 Thread Chris Matthews
Hi Bobby,

See 
http://adil.2scomplement.com/2008/05/django-add-choices-to-form-fields-on-runtime/

Try something like the following:

# Define your choices
LOCATION_CHOICES = ((1,'location1'),
(2,'location2'),
(3,'location3'),
(4,'location4'),
   )

LOCATION_CHOICES_PUBLIC = ((1,'location1'),
(2,'location2'),
(3,'location3'),
   )

Example 1
-
class ProfileForm(forms.Form):
class Meta:
model = Profile

locations = forms.ChoiceField(required=True)

def __init__(self, *args, **kwargs):
# This is a bit of a hack
if 'user_type' in kwargs and kwargs['user_type'] == 'public':
public = True
# We do not want to pass our kwarg to super
del kwargs['user_type']
else:
public = False

super(ProfileForm, self).__init__(*args, **kwargs)

if 'user_type' in kwargs and kwargs['user_type'] == 'public':
self.fields['locations'].choices = LOCATION_CHOICES_PUBLIC
else:
self.fields['locations'].choices = LOCATION_CHOICES

In your module use
form = ProfileForm(user_type='public')
or
form = ProfileForm()

Example 2
-
class ProfileForm(forms.Form):
class Meta:
model = Profile

# the limited choices are our default
locations = forms.ChoiceField(choices = LOCATION_CHOICES_PUBLIC, 
required=True)

In your module
form = ProfileForm()
if not public:
form.fields['locations'].choices = LOCATION_CHOICES


Example 2 is a bit 'cleaner'/neater I think.

Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Bobby Roberts
Sent: 16 February 2011 15:14
To: Django users
Subject: Re: form select box how to (help needed)

i have no idea what this means is there an example anywhere?

On Feb 16, 12:43 am, Kenneth Gonsalves  wrote:
> On Tue, 2011-02-15 at 19:05 -0800, Bobby Roberts wrote:
> > I can't load it through the "CHOICES" parameter in my forms field...
> > how can I do this?
>
> override __init__ in your form and populate there
> --
> regards
> KGhttp://lawgon.livejournal.com
> Coimbatore LUG roxhttp://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: 'str' object is not callable

2011-02-16 Thread Chris Matthews
Hi Patrick,



You can typically get it by:

1)missing the % for a string format:

  x = "Hello number %d" (5)

  TypeError: 'str' object is not callable



2) And if you overwrite a function name with a string, e.g."

>>> min(5,2,3)

2



>>> hour,min,sec = "14:59:03".split(":")

>>> min(5,2,3)

TypeError: 'str' object is not callable



Just check your recent code.



Regards

Chris



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Szabo, Patrick (LNG-VIE)
Sent: 16 February 2011 14:03
To: django-users@googlegroups.com
Subject: 'str' object is not callable



Hi,



Im getting 'str' object is not callable and i have no idea why.

What I'm doing is the following:



delete



buchung is a list and the 6th element oft hat list is an object with an

attribute id.



In my urls.py i did this:



(r'deletion_time/(?P\d+)/$', 'deletion_time'),



And the view looks like this:



def deletion_time(request, obj_id):

buchung = Buchung.object.filter(id = obj_id)

buchung.delete()

return HttpResponseRedirect('/main/')



Can anyone tell me what's causing this error ?!



Kind regards



. . . . . . . . . . . . . . . . . . . . . . . . . .

Patrick Szabo

 XSLT-Entwickler

LexisNexis

Marxergasse 25, 1030 Wien



mailto:patrick.sz...@lexisnexis.at

Tel.: +43 (1) 534 52 - 1573

Fax: +43 (1) 534 52 - 146











--

You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.

To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.

For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Importing modules in code

2011-02-16 Thread Chris Matthews
Hi Galago,

For some conventions see 
http://docs.djangoproject.com/en/dev/internals/contributing/?from=olddocs#django-conventions
and http://www.python.org/dev/peps/pep-0008/

Generally I do imports at the top of the module in this order (with a blank 
line inbetween):

1.   python modules

2.   django modules

3.   3rd party modules

4.   Your project/application modules

Regards
Chris

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of galago
Sent: 16 February 2011 10:39
To: django-users@googlegroups.com
Subject: Importing modules in code

Is it a good idea to import modules in the middle of the code, and not on the 
beginning?
I want to make a hash generation. It's few lines - it's used once in all 
application. Should I import hashlib just on the beginning of the file? Now I 
put it with the rest of the code.
Is it bad?

I don't want to import it with all requests in my app view.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Progress Bar/ProgressBarUploadHandler Documentation Examples

2011-02-15 Thread Chris Matthews
Hi Hank,

I just got the book "jQuery UI 1.7" by Dan Wellman. Chapter 8 covers 
Progressbar. Have not worked through it yet so I can't give my view on it.

Regards
Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of hank23
Sent: 16 February 2011 00:27
To: Django users
Subject: Re: Progress Bar/ProgressBarUploadHandler Documentation Examples

Are there any other good options or coding examples besides this one
or is it the best and most complete?

On Feb 15, 8:20 am, Derek  wrote:
> Fortunately, other clever coders have written up on 
> this:http://fairviewcomputing.com/blog/2008/10/21/ajax-upload-progress-bar...
>
> On Feb 14, 4:56 pm, hank23  wrote:
>
>
>
> > Are there any exampels of how to code Progress bars or the handlers
> > which support them somewhere in the django documentation? they're
> > referenced in the documentation, but without showing any actual coding
> > examples.- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Saving multiple records from admin list page

2011-02-15 Thread Chris Matthews
Hi Sithembewena,

If you want to monitor changes to tables then you might also be interested in 
keeping audit/history records. See the book ProJango by Marty Alchin Chapter 11 
(page 263 onwards) and http://qr7.com/2010/10/django-simple-history-ftw/  by 
Corey Bertram

Regards
Chris

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Sithembewena Lloyd Dube
Sent: 15 February 2011 11:17
To: django-users@googlegroups.com
Subject: Saving multiple records from admin list page

Hi all,

In my admin.py, I overrode the save() function of a model as follows:

from myproject.myapp.functions import 
send_staking_request_status_notification_email

def save_model(self, request, obj, form, change):
  staking_request = obj
  obj.save()
  send_staking_request_status_notification_email(staking_request)

Therefore, when an admin user logs in and saves a record, an email is sent off 
to a site member. The function that does the emailing is imported from a custom 
module and this works fine.

However, on the list page of said model in the admin area, the admin user is 
also able to select an action to apply to multiple records. How can I modify my 
admin.py so that the save() override specified above
fires for all records?

Thanks.
--
Regards,
Sithembewena Lloyd Dube
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Django Form Doesn't Render

2011-02-14 Thread Chris Matthews
Hi Dean,



Looks like you pass the class ContractForm in to your render (and not the 
variable contractForm). Also on naming (PEP 8) contract_form would have been 
nicer for the variable (and would have stood out more so that the error was 
easier to spot).



Regards

Chris



-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Dean Chester
Sent: 15 February 2011 00:25
To: Django users
Subject: Django Form Doesn't Render



Hi,

I have written a form in forms.py that looks like this:

class ContractForm(forms.Form):

  title = forms.CharField()

  start_date = forms.DateField()

  end_date = forms.DateField()

  description = forms.CharField(widget=forms.Textarea)

  client = forms.ModelChoiceField(queryset=Client.objects.all())



And in my view (yes i know there are problems with data not being

checked but the aim was to get the client field to display clients

associated with that user):

def addContractTEST(request):

  if request.method == 'POST':

contractForm = ContractForm(request.POST)

title = request.POST['title']

start_date = request.POST['start_date']

end_date = request.POST['end_date']

description = request.POST['description']

client = request.POST['client']

user = request.user

contract =

Contract(title,start_date,end_date,description,client,user)

contract.save()

return HttpResponseRedirect('../../accounts/profile/')

  else:

user = request.user

print user.username

contractForm = ContractForm()

return render_to_response('newcontract.html', {'ContractForm':

ContractForm})



And my newcontract.html:



 





  {% if contractForm.errors %}

  

Please correct the error{{ contractForm.errors|pluralize }} below.

  

  {% endif %}

  



  {{ contractForm.as_p }}



  



  



But all that appears is my submit button so what am I doing wrong?



Thanks in Advance,

Dean



--

You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.

To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.

For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Need a tutorial for 'regexpr'

2011-02-10 Thread Chris Matthews
Hi Navaneethan,

It is like riding a bicycle; initially you falter a bit but later you ride with 
style.

See http://www.regular-expressions.info/tutorial.html and 
http://www.regular-expressions.info/javascript.html

Try not to build too complex expressions; always think of the guy who has to 
maintain it long after you have coded it.

Run /Python26/Tools/Scripts/redemo.py to interactively test your regular 
expressions. It works really well.
If you want to use and see named groups you can update redemo.py with:
Between line 150 and 151: 
 self.grouplist.insert(END, g)
nmatches = nmatches + 1

Insert (de-dented once, same as for line 148):
#_Start Chris Matthews 
10 May 2005
self.grouplist.insert(END, "Named Groups:")
GroupDict = m.groupdict()
if GroupDict:
   self.grouplist.insert(END, "{")
   keysGroupDict = GroupDict.keys()
   keysGroupDict.sort()
   for Name in keysGroupDict:
  self.grouplist.insert(END, "'%s': '%s'" % (Name, 
GroupDict[Name]))
   self.grouplist.insert(END, "}")
lstFindAll = self.compiled.findall(text)
self.grouplist.insert(END, "\nFindAll: %s" % (lstFindAll))

   
Here is a nice quick reference to print and keep close by:
=
 Regular Expression Primitive Quick Reference
Regular expressions can contain both special and ordinary characters. Most 
ordinary characters, like "A", "a", or "0", are the simplest regular 
expressions; they simply match themselves. You can concatenate ordinary 
characters, so last matches the string 'last'. 
Some characters, like "|" or "(", are special. Special characters either stand 
for classes of ordinary characters, or affect how the regular expressions 
around them are interpreted. 
The special characters are: 
.   (Dot.) In the default mode, this matches any character except a 
newline. 
^   (Caret.) Matches the start of the string. 
$   Matches the end of the string. 
*   Match 0 or more repetitions of the preceding RE.
+   Match 1 or more repetitions of the preceding RE. 
?   Match 0 or 1 repetitions of the preceding RE. 
{m} Specifies that exactly m copies of the previous RE should be matched. 
{m,n}   Causes the resulting RE to match from m to n repetitions of the 
preceding RE.
\   Escapes special characters ("*", "?", or \a \b \f \n \r \t \v \x \\)
[]  Range of characters e.g. [0-3A-C]  for 0123ABC,  [^5] match any except 
"5".
|   Or
()  Group
(?P...) Named group

Regular Expression Extended Quick Reference
\d  Any decimal digit; same as [0-9]. 
\D  Any non-digit character; same as [^0-9]. 
\s  Any whitespace character; same as [ \t\n\r\f\v]. 
\S  Any non-whitespace character; same as [^ \t\n\r\f\v]. 
\w  Any alphanumeric character and the underscore; same as [a-zA-Z0-9_].
\W  Any non-alphanumeric character; same as [^a-zA-Z0-9_].
=


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Kenneth Gonsalves
Sent: 11 February 2011 08:50
To: django-users@googlegroups.com
Subject: Re: Need a tutorial for 'regexpr'

On Thu, 2011-02-10 at 22:47 -0800, NavaTux wrote:
> Do you know any elegant tutorial to learn a regular 
> expression from a nutshell ? i have referred some links which are
> given in 
> a syntax without simple example, just i need a simple examples with
> clear 
> explanation even i tried in past two days to pick it 

http://www.python.org/doc//current/howto/regex.html
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: VPython and Django

2011-02-10 Thread Chris Lyon
It's fairly hard, Visual doesn't have an easy mechanism for rendering 
png files.
One way is to render an equivalent from pov-ray. But in some ways that a 
different question.




On 10/02/11 16:34, Juan Kepler wrote:

How I can incorporate in a web a 3D image made with VPython using
Django?



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Calling out for Help!

2011-02-08 Thread Chris Hannam
I have found http://stackoverflow.com/questions/tagged/django to be an
awesome resource.

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking for IDE + FTP

2011-02-08 Thread Chris Hannam
I really enjoy Wing IDE, it has an excellent debugger. It won't do
your ftp stuff but it will make solving bugs a lot easier.

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: cannot login to admin site using admin credentials

2011-02-07 Thread Chris Lawlor
Try running 'python manage.py createsuperuser' on your production
server to create a new superuser account. You should have full
privileges to log in to the admin and make changes using this account.

On Feb 7, 8:15 am, xpanta  wrote:
> Hi,
>
> it seems that my problem is a bit complicated. I have tried much but
> to no avail. So, please help me!
>
> Some time ago I migrated to postgresql from mysql. I don't know if I
> did something wrong. Anyway, my webapp works "almost" flawlessly.
>
> Since then I never needed to login using admin rights (either using
> the admin panel or my web site). Some weeks ago I tried and I noticed
> that I can't login (to both admin site and web page) using admin
> credentials.
>
> I have tried dozens of various tricks but I still can't login.
>
> I tried adding user.set_password()  to my views.py in order to replace
> admin password with a new simpler one ('123') but nothing. I even
> registered a new user from my web page and changed its fields directly
> in the DB (is_staff, is_active, is_superuser) to 'True'. This let me
> login to the admin site but gave me no permission to change anything.
> I even tried to create various admin users with the help of django
> shell but none of them gives me a login. Interestingly whenever I do
> something to change admin password, I always see a different hashed
> password value in my DB. This means that all my approaches succeed in
> changing the admin password. However I can't login.
>
> Normal users work fine. Problem appears only when the user is an
> administrator.
>
> Any help would be greatly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Database per user

2011-02-06 Thread Chris Hannam
Hi,

http://docs.djangoproject.com/en/1.2/topics/db/multi-db/ contain
information about setting up multiple databases. I personally have no
idea how this would scale to may users.
If you are looking to store large amounts of data I would look at an
alternative to SQLite. I have found http://www.postgresql.org/ to work
very well with large datasets.

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: File Upload

2011-02-06 Thread Chris Hannam
Hi,
startswith is usually a string method. Looks like something is calling
.startwith() on a tuple rather than the expected string.

When you instantiate your model are you certain all the values are correct?
Try logging all the values before creating the model and look for a tuple
where there should be a string.

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Amazing work

2011-02-05 Thread Chris Hannam
Hi,
Plone (which runs on Zope) is not that unusual a CMS system for business. It
suffers from a lack of documentation like Zope but there is a pretty
thriving community behind Plone currently.

Certainly worth a look if nothing else.

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help on adding CSS to django project

2011-02-04 Thread Chris Hannam
Apologies for that premature send:


> Hi,
> The way I have approached this is to have a static dir set in my urls.py:
>

>
(r'^static/(?P.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT }
 )

settings.py has the following
MEDIA_ROOT = os.path.join(PATH_SITE_ROOT, 'static')
PATH_SITE_ROOT = os.path.normpath(os.path.dirname(__file__))

I reference the css files in the html as /static/css/style.css etc

The urls.py maps the url to the location on disk of the css files.

Can you supply the error messages and some of your config if you are still
having issues?

CH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help on adding CSS to django project

2011-02-04 Thread Chris Hannam
>
> Hi guys,
> am very new to django and am having troubles adding css to my pages
> even though i've found some tutorials online
> and followed it word for word.


Hi,
The way I have approached this is to have a static dir set in my urls.py:

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Adding popups for edit

2011-02-02 Thread Chris Matthews
Hi Marco,

Again the book "Django JavaScript Integration: AJAX and jQuery" by Jonathan 
Hayward. In Chapter 6 he covers jQuery In-place editing by using 
http://www.appelsiini.net/projects/jeditable

PS: I have never met Jonathan, I live far-away in Africa, so I am not plugging 
his book. I happen to read it currently and it seems to cover the questions.

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Dekker
Sent: 02 February 2011 12:44
To: Django users
Subject: Adding popups for edit

Hi

Django Admin includes Popups for adding (FK) records by clicking the
"+"-image next to the foreign key.

I would like to add an "edit"-button, that would allow for a popup to
edit the currently selected entry. Can I "copy" the behaviour of the
"+"-image (showAddAnotherPopup and dismissAddAnotherPopup) or is there
a reason why this was never implemented?

Any supporting hints will be gladly taken!

Thanks,
Marco

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Filtered drop down choice django

2011-02-02 Thread Chris Matthews
Hi Sushanth,

I am currently working through the book "Django JavaScript Integration: AJAX 
and jQuery" by Jonathan Hayward. In Chapter 7 he covers autocomplete (see 
http://jqueryui.com/ or more specifically 
http://jqueryui.com/demos/autocomplete/) to handle filtered drop down.


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Andre Terra
Sent: 02 February 2011 12:05
To: django-users@googlegroups.com
Subject: Re: Filtered drop down choice django

Patches are welcome!
On Wed, Feb 2, 2011 at 07:48, Derek 
mailto:gamesb...@gmail.com>> wrote:
I suspect I am not the only one really hoping for An Official Way to
be developed at some time...

In the meantime, also look at:
http://www.stereoplex.com/blog/filtering-dropdown-lists-in-the-django-admin

I think this is quite detailed and has some good comments as well.

On Feb 1, 7:07 pm, shacker 
mailto:shac...@birdhouse.org>> wrote:
> On Jan 31, 6:40 am, sushanth Reddy 
> mailto:sushant...@gmail.com>> wrote:
>
> > I am trying to create a dynamic filtered drop down choice fields,i gone
> > through below blog but it confusing,can any one suggest easy way to do this
> > in django.
>
> Do you mean in the admin or on your live site? If in the admin,  check
> out the docs on ModelAdmin.formfield_for_foreignkey:
>
> http://docs.djangoproject.com/en/1.1/ref/contrib/admin/
>
> class MyModelAdmin(admin.ModelAdmin):
> def formfield_for_foreignkey(self, db_field, request, **kwargs):
> if db_field.name == "car":
> kwargs["queryset"] =
> Car.objects.filter(owner=request.user)
> return db_field.formfield(**kwargs)
> return super(MyModelAdmin,
> self).formfield_for_foreignkey(db_field, request, **kwargs)
>
> If you're trying to do this on your live site, you can do whatever
> filtering you like in your view of course.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to 
django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Django SQL Query does not stop

2011-02-01 Thread Chris Matthews
Hi Ivo,

SQL is like regular expressions. You can go complex (with one mega 
query/expression) but it could create a maintenance nightmare. See if you 
cannot simplify the query into multiple queries and a bit of code (for loops 
and using the joining columns) to lash them together. The code sequence should 
be such that you limit access to a huge amount of rows; so you filter the data 
accessed. It is usually easier to debug as well. And using Tom's advice 
(EXPLAIN SELECT ...) on smaller join queries is often more useful (than the 
explain on a mega join query).

In my experience it often runs way faster if the query is simplified.

Regards
Chris
-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Ivo Brodien
Sent: 01 February 2011 23:49
To: django-users@googlegroups.com
Subject: Re: Django SQL Query does not stop

I found a solution be changing the MySQL server setting optimizer_search_depth 
to 3 (default 62)

http://dev.mysql.com/doc/refman/5.0/en/controlling-optimizer.html
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_optimizer_search_depth

My query had over 20 INNER JOINTS and it made the optimizer search a long 
process.

So at the moment a value of 3 is fine.

On 01.02.2011, at 21:20, Ivo Brodien wrote:

> The Change List that I am calling is a Intermediate Table if that is of any 
> interest.
> 
> Is it possible that there is some sort of circular inner joints or something?
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Django Template CSS Load Path

2011-01-30 Thread Chris Matthews
change
href='{{ MEDIA_URL }}/static/PageStyle.css' />
to
href='{{ MEDIA_URL }}static/PageStyle.css' />

-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of octopusgrabbus
Sent: 29 January 2011 21:17
To: Django users
Subject: Re: Django Template CSS Load Path

I still cannot get the css page to load.

On Jan 19, 4:02 pm, Matías Iturburu  wrote:
> On Wed, Jan 19, 2011 at 5:30 PM, Eduardo Cereto Carvalho <
>
> eduardocer...@gmail.com> wrote:
> > You can use MEDIA_URL conf to get the root path to your media files.
>
> >  > />
>

My MEDIA_URL is MEDIA_URL = 'http://localhost:8002/'

I have added 
to my base template.

I'm not sure what changes I'm supposed to make regarding
TEMPLATE_CONTEXT_PROCESSORS. I don't have that constant in my
settings.py nor do I have   'django.core.context_processors.request'
or 'django.core.context_processors.media' in any of my application
files.

tnx
cmn

> the above code is correct, just make sure that you are using the media
> context processor or returning a RequestContext, not just plain Context.
> Check out your settings.py for this one of this in the
> TEMPLATE_CONTEXT_PROCESSORS constant.
>
> 'django.core.context_processors.request',
> 'django.core.context_processors.media',
>
>
>
>
>
> > On Wed, Jan 19, 2011 at 5:55 PM, octopusgrabbus  > > wrote:
>
> >> I am trying to load a css file in my base.html template
>
> >> 
> >>
> >>
> >>{% block title %}Test{% endblock %} 
> >>
> >>   
>
> >> What kind of path is supposed to go in the href? Is it relative to the
> >> document root?
>
> >> Does anyone have an example of loading a css file including the Apache
> >> configuration?
>
> >> Thanks.
> >> cmn
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Eduardo Cereto Carvalho
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Matías Iturburuhttp://www.linkedin.com/in/miturburu|http://ltmo.com.ar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: abstract base class and overwriting save()

2011-01-28 Thread Chris Matthews
The "save def save(self, *args, **kwargs):" should not have the leading save.

Also, if you are making a car system then this structure seems more appropriate:
class CarMake(models.Model):
   ...


class Car(models.Model):
   make = models.ForeignKey(CarMaker)
   ...
 def save(self, *args, **kwargs):
do_something()
super(Car, self).save(*args, **kwargs)



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Daniel Roseman
Sent: 28 January 2011 11:36
To: django-users@googlegroups.com
Subject: Re: abstract base class and overwriting save()

On Friday, January 28, 2011 9:21:48 AM UTC, Jaroslav Dobrek wrote:
Hi,

if I have got several models that have identical code, except for
their save method, how can I use an abstract base class for them? Will
I have to overwrite save() for each model? Or is there a generic way
to define save(), i.e. a way that I have to use only once -- in the
abstract base class?

class BMW(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(BMW, self).save(*args, **kwargs)

class Fiat(models.Model):
   ...
  save def save(self, *args, **kwargs):
do_something()
super(Fiat, self).save(*args, **kwargs)

Jaroslav

The whole point of subclassing is that subclasses inherit models from the 
superclass. That's how the model save() method is definted in the first place, 
if you don't override it. What exactly are you having problems with?
--
DR.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Challenge with installing django on windows 7 64 bit

2011-01-26 Thread Chris Matthews
1) Generally "not a valid archive" means the file was corrupted during the 
download/copy or the download/copy did not complete. If you used ftp to copy 
the file and the file mode settings was ASCII (not binary) then you can have a 
corrupt file (because CR 0x0D gets converted to CRLF 0x0D0A). If that is the 
case then download it again. You can confirm it was corrupt if you keep the 1st 
version of your archive and compare it with the 2nd one (using DOS/Windows file 
compare command: comp file1 file2

2) You can see if Python's gzip likes your archive (from Python help):
import gzip
f = gzip.open('/home/joe/file.txt.gz', 'rb')
file_content = f.read()
f.close()

3) If it is a 64 bit/Windows 7 issue then:
Have you tried changing your 7z's compatibility settings to run it in an older 
mode? In explorer: Right-click on exe file -> properties -> compatibility -> 
"Run this program in compatibility mode for" and then choose Windows XP


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Magge
Sent: 26 January 2011 19:24
To: Django users
Subject: Challenge with installing django on windows 7 64 bit

Hi,

I am trying to extract the installation files from the
Django-1.2.4.tar.gz file that I got from the django website. I tried
using winzip, 7z, cygwin and so forth. All these programs complain
that the file isnt a valid archive.

I used to work with django back in 2009 on Window. The installation
used to be off the extract of a zip file I remember. How do I get
going with the installation?

I appreciate any inputs on this

Thanks
Keshav Magge

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: forbid clones

2011-01-26 Thread Chris Matthews
Have a look at unique_together:
Django | Model Meta options | Django documentation
http://docs.djangoproject.com/en/dev/ref/models/options/

Jump to unique_together‎: Options.unique_together¶. Sets of field names that, 
... For convenience, unique_together can be a single list when dealing ...
docs.djangoproject.com/en/dev/ref/models/options/
Labeled Latest docs  1.0 docs  All docs


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Jaroslav Dobrek
Sent: 26 January 2011 14:26
To: Django users
Subject: Re: forbid clones

>
> http://docs.djangoproject.com/en/1.2/ref/models/fields/#unique

Although this does help, it leaves one question open:

How can we forbid only such pairs of objects that have the same value
in all of their attributes.

Example:

This should be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "baz"

This should not be allowed:

car1: manufacturer = "foo", name = "bar"
car2: manufacturer = "foo", name = "bar"


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: DB-Views or read-only tables in models

2011-01-25 Thread Chris Matthews
Not sure if http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ 
will be of some help. See admin.site.disable_action('delete_selected')
; but this is only via the admin app. You could build some logic in the model 
by overriding the save() method, conditionally, based upon user. So your 
developers/administrators can have full access but 'normal' users not.


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of bvdb
Sent: 25 January 2011 18:20
To: Django users
Subject: DB-Views or read-only tables in models

A developer sometimes has to access and present data that existed
before his application. Common practice is for a database
administrator to define a database view (with a CREATE VIEW sql
command, not to be confused with the V in MVC) and give the Django
developer access to this. This is only a read access because in most
cases it is not possible or desireable to allow an UPDATE on a view.

Now I am new to Django, have some experience with databases - and
couldn't find a "read-only attribute" when defining a model.
Without knowing that a view - that is accessed with the same SELECT
syntax as a table - is read-only Django would for example generate an
admin interface that produces errors, and leave the user wondering
why.
It makes also sense in some cases to define a table read-only for a
model even it is fully accessible by the Django team.

Is it really not possible to define read-only access in Djangos ORM?
Or maybe I just overlooked the description?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: URL -> query problem --- doesn't seem to be cache-related

2011-01-14 Thread Chris Lee
Thanjs -- I'll give that a shot.

On Jan 14, 9:16 am, bruno desthuilliers
 wrote:
> The canonical way to encode search arguments in an URL is to use the
> querystring.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



URL -> query problem --- doesn't seem to be cache-related

2011-01-14 Thread Chris Lee
Hi Django gurus,

I'm coding-up a failure tracking database, and came up with what I
thought was a straightforward way to encode different searches into
part-failures via a single URL pattern.

In urls.py:

 url(r'^part_failure_list(/project/(?P\d+))?(/platform/(?
P\d+))?(/hw_category/(?P\d+))?(/
hw_subcategory/(?P\d+))?', #more stuff like
this
  'tracker.track.views.part_failure_list',
{ 'nav_context': nav_context },
'part_failure_list'),
)

Then in views.py, the function 'part_failure_list' looks for the
existence of each of the keyword arguments and filters the query
appropriately.  The resulting html page offers links that 'unselect's
each selected keyword (removes them from the url) and links that
further restrict the query (adds more keywords to the url).

When I click on a link that further restricts the query (adding more
keywords into the url) I get the expected result.  THE PROBLEM IS that
when I click on a link that unselects a keyword, my browser shows an
html page where the keyword is still selected.  I have to restart
apache and reload the page to get the expected html page.

I've verified that the links to unselect keywords are correct.  I set
the CACHE_BACKEND to dummy, and used @cache_control(no_cache=True) to
try to turn off caching (in case the cache is malfunctioning).  I used
Chrome and Firefox to see if there is a browser cache problem on one
or the other.  I did a 'python manage.py runserver' on the web server
and used the lynx browser on the web server and still reproduced the
problem.  So I'm wondering if somehow this relates to how urls are
dispatched by Django(???).

Any suggestions?

I'm using:
 Django-1.2.1 (installed from the Django web site) running on an
ubuntu server.
 I'm running apache2 with mod_wsgi.
 I'm using MySQL 5.1.41

Thanks,
 -Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: empty DateTimeField?

2011-01-11 Thread chris
As Justin mentioned,  my guess is that you would have to manually
update the table definition to allow nulls for that column.

On Jan 11, 7:21 pm, galago  wrote:
> I tried but I get:
> Exception Type: IntegrityError Exception Value:
>
> (1048, "Column 'publish_date' cannot be null")
>
> Exception Location: C:\Python27\lib\site-packages\MySQLdb\connections.py in
> defaulterrorhandler, line 36
>
> Field definition: publish_date = models.DateTimeField(editable=False,
> blank=True, null=True)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django's documention is horrible

2011-01-10 Thread Chris Czub
Yup, that is my approach...

The Django sourcecode is eminently readable and well-organized and most of
it has documentation associated with it.

You can jump into a shell and use the help() command to view API
documentation like you requested.

e.g.

>>> help('django.contrib.auth.models.User')

On Mon, Jan 10, 2011 at 5:02 PM, Ovnicraft  wrote:

>
>
> On Mon, Jan 10, 2011 at 4:53 PM, Sam Walters  wrote:
>
>> Hi,
>> My approach with regard to:
>>
>> > frameworks I'm used to have at least a well structed API documention
>> listing
>> > all methods and members of classes with some comment attached to them.
>> They
>> > also show the class heirachy, quick and simple.
>>
>> I just look at the source itself for this.
>>
>
> or use pydoc
>
>>
>>
>> cheers
>>
>> sam_w
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>
> --
> Cristian Salamea
> @ovnicraft
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: list of lists in template

2011-01-07 Thread Chris Matthews
{%  for Ltarp in  smth.3 %}
SHOULD BE 
{%  for Ltarp in  smth.2 %}
'cos Lans only has 3 elements and Ltarp is Lans[2].

Chris

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of gintare
Sent: 07 January 2011 08:52
To: Django users
Subject: list of lists in template


in view.py
...
Ltarp.append([item.Wordword, item.WordTranslEn, item.WordNotesGram,
item.WordConcl])
..
Lans.append([sen.Sent, sen.SentTransl, Ltarp ] )

in template.html
{% if Lans %}

{%  for smth in Lans %}

  {{smth.0}} 

{%  for Ltarp in  smth.3 %}

 {{Ltarp.0}} 


{% endfor %}


{% endfor %}

{% endif %}

###

the rows from smth.0 are shown
the rows from  Ltarp in  smth.3, i.e. {{Ltarp.0}} are not shown.

I tried also:Ltarp, Ltarp[0], smth.Ltarp.0

nothing works in the second for cycle where i need to get items from
list built in third item of list in the first for cycle.

Could you please help with syntax, when i need to dislay item from
list in another list in template

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?

2011-01-04 Thread Chris Seberino

Nevermind.  I figured it out.  To only have subdirs by static you need
to add a "/" at the end of an Alias line...

e.g.

Alias /books/   /some/static/dir/

Thanks!

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?

2011-01-04 Thread Chris Seberino
On Jan 4, 2:48 am, Graham Dumpleton 
wrote:
> If using Apache/mod_wsgi it is quite simple, and wouldn't even need URL
> rewriting as suggested by others.
>
> So, what are you hosting it with.

Yes I am using mod_wsgi.  The following line sends all URLs to WSGI
script

WSGIScriptAlias//etc/apache2/wsgi/phil4.com.wsgi

I also have other Alias lines like this..

Alias  /images  /var/www/static/images

What is tricky about this current problem is I want to send /books to
WSGI but NOT /books/* .

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?

2011-01-03 Thread Chris Seberino
How configure Django to handle /books URL and yet allow access to PDFs
and images in subdirs of /books?

Specifically, I want /books to be a dynamic page with lots of links to
PDFs and images of book covers contained in subdirectories of /books
like /books/some_book_1 and /books/some_book_1/book_cover.jpg.

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: loading the external css file

2011-01-03 Thread Chris Lawlor
If you don't have a staticfiles module, you most likely aren't using
Django 1.3. Make sure you select the correct version of Django when
viewing the docs, as things are often done differently in older
versions, but the doc pages usually default to the latest SVN release.

On Dec 27 2010, 10:43 pm, Bithu  wrote:
> When i was trying to set my static files. When i added the
> 'django.contrib.staticfiles' into INSTALLED_APP in my setting.py the
> development server was not running showing an error  Error: No module
> named staticfiles.
>
> On Dec 27, 7:07 pm, Chris Lawlor  wrote:
>
>
>
>
>
>
>
> > Django doesn't server static files (like your CSS file) by default -
> > but you can configure the development server to do 
> > so:http://docs.djangoproject.com/en/dev/howto/static-files/
>
> > Note that this has changed a lot in Django 1.3, so be sure to view the
> > correct version of that page for the version of Django that you are
> > using.
>
> > In production, you should almost always configure another server to
> > serve static files.
>
> > On Dec 27, 8:29 am, Bithu  wrote:
>
> > > When i was trying to load an external stylesheet it was not working.
> > > But the internal css is working nicely.
>
> > > What should i do to link my .css file to my html template which is
> > > inside my template folder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ModelForm Field not display choice text

2010-12-27 Thread Chris Lawlor
Michael,

In one of my projects, I did something like this:


{% for field in rating_form %}
{{ field}}
{% endfor %}



$('#stars').children().not(":radio").hide()
$('#stars').stars({
cancelShow: false,
callback: function(ui, type, value){
ajaxVote(value);
}
});

function ajaxVote(value) {
$.ajax({ url: '{% url plugin-rate object.slug %}',
 type: 'POST',
 data: { rating: value },
 dataType: 'json',
 success: function(data){
var avg_rating = data['avg_rating']
var votes = data['votes']
$('#rating_display').html(avg_rating +" out of 5 (Rated " +
votes + " times)")
 },
});
}

The key to hiding the other form elements (like the labels) is the $
('#stars').children().not(":radio").hide() call, which basically hides
everything but the actual stars. If the use doesn't have JS enabled,
they should still see the radio buttons with the associated labels.

Hope that helps,

Chris

On Dec 27, 6:48 am, Michael Thamm  wrote:
> One thought, and this maybe the whole issue, is that the radio button
> is using labels for the text and not titles.
> I would expect the output to be something like this:
> 
> but instead the output is like this:
> 
>     
>   1
> 
>
> Is this something that anyone else has had to deal with?
>
> Thanks
> Michael
>
> On Dec 27, 6:39 am, Michael Thamm  wrote:
>
>
>
>
>
>
>
> > Hi,
> > I am using the jQuery stars on a radio field as a custom renderer. The
> > stars come up nicely but the
> > choice text still displays to the side of the stars.
> > How can I not show the choice text but still populate the field with
> > the choice result?
> > I am displaying the field in the template like this:
> > {{ userForm.fitStars }}
>
> > BTW - I am not talking about the label text. For example,
> > How was your meal?
>
> > But rather the radio button choices.
>
> > The radio button text I want to not display.
>
> > Thanks
> > Michael

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: loading the external css file

2010-12-27 Thread Chris Lawlor
Django doesn't server static files (like your CSS file) by default -
but you can configure the development server to do so:
http://docs.djangoproject.com/en/dev/howto/static-files/

Note that this has changed a lot in Django 1.3, so be sure to view the
correct version of that page for the version of Django that you are
using.

In production, you should almost always configure another server to
serve static files.

On Dec 27, 8:29 am, Bithu  wrote:
> When i was trying to load an external stylesheet it was not working.
> But the internal css is working nicely.
>
> What should i do to link my .css file to my html template which is
> inside my template folder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Load file into a FileField

2010-12-21 Thread Chris Lawlor
Liriela,

AFAIK it is not possible to programmatically populate a file input
field, due to the many security exploits this would enable. If it were
possible, it would be trivial to write a malicious script that would
upload any file from a user's PC, so long as you knew the path.

There are browser-specific exceptions, for example, in Netscape-based
browsers you can call
netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead")
(see 
http://www.mozilla.org/projects/security/components/signed-script-example.html).
This needs to be called from a signed script, and I believe will still
trigger a pop-up dialog to confirm the enhanced permission request. I
imagine this might be more trouble than it's worth though.

As an alternative testing method, you might consider using curl. You'd
do something like:

curl http://localhost:8000/submit/test -F id_title=Test -F
id_email=em...@test.org -F id_file=@/path/to/test.txt -u
username:password

Note the @ symbol in front of the value for file_id - that tells curl
that the value is a file, not a string.

I've only really used this method when testing an API which returned
JSON data, which is easily viewable in the console. If your view is
returning HTML, you might pipe the output to a file to open in a
browser.

Hope that helps,

Chris

On Dec 21, 5:14 am, Liriela  wrote:
> Hi there,
>
> I am working now on a web server and come up with a problem. I want to
> have on my site a button which will load test data into a form -> for
> example -> a form has fileds: name and email -> the button will load
> into the fields values defined by me. That is not a problem for all
> the data that is served by request.POST. But the problem shows up when
> I have a FileField in my forms and I want to load a file into that
> field. The solution that I have found probably loads somehow the file
> into request.FILES dictionary (so the file is bound to the form) -
> because there is no non-field error shown, but after pressing the
> submit button the non field error occurs (so the file is lost). And
> the name of the file is not shown in the form. (I am using django
> version 1.2.3 and python version 2.6.6 )
>
>  Here are my forms, views and template for that:
>
> forms.py
> (...)
> class Test(forms.Form):
>     ''''''
>
>     title          = forms.CharField(max_length = 30, required = True)
>     email       = forms.EmailField(required=False)
>     test_file    = forms.FileField()
>
> views.py
>
> from django.core.files.uploadedfile import SimpleUploadedFile
> (...)
> def load_test_analysis(request):
>     """ """
>     f = open('/path/test.txt','r')
>    post_data =  {'title':'Test ',
>                         'email' : 't...@test.org'}
>     file_data = {'alignment': SimpleUploadedFile('test.txt',
> f.read())}
>     form = Test(post_data, file_data)
>     return render_to_response('test.html', {'form': form})
>
> test.html
>
> {% extends 'master.html' %}
>
> {% block content %}
>
> 
>
> 
>     
>         
>             Teste
>         
>         
>              
>         
>     
> 
>
>  action="/submit/test/">
>
> Title: {{ form.title }}
> {{ form.title.errors }}
> 
>
> File: {{ form.file }}
> {{ form.file.errors }}
> {{ form.non_field_errors }}
>
> Email: {{ form.email }}
>  {{form.email.errors}} 
> 
>
> 
> 
> 
>
> 
>
> {% endblock %}
>
> Hope someone will be able to help me with that.
>
> Best,
> Liriela

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: more than one querys LIKE in the same field

2010-12-14 Thread Chris Lawlor
Not to second guess your intent, but are you sure you don't mean to OR
the two? Your current SQL / Django query will only return tags that
have both 'candy' and 'milk' in the tags string.

If you do want to OR the queries, you can use Q objects:

from django.db.models import Q
table.objects.filter(Q(tags__icontains='milk') |
Q(tags__icontains='candy'))

Also note that, if you're using sqlite, case-insensitive string
lookups are not supported (see 
http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching).

Hope this is helpful,

Chris

On Dec 14, 3:10 am, marcoarreguin  wrote:
> Hi friends!
>
> I mean do something like this:
>
> SELECT * FROM table WHERE tags LIKE '%candy%' AND  tags LIKE '%milk%'
>
> I've tried:
>
> table.objects.filter(tags__icontains='candy', tags__icontains='milk')
>
> I've tried too:
>
> list = ['candy', 'milk']
> table.objects.filter(tags__icontains=list
>
> And nothing work. Help me please :s
>
> Thanks bros!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Weird problem after schema change

2010-11-30 Thread chris
Nope, haven't defined anything interesting for admin. The field name
matches, as far as I know.

Frankly, though, given the length of time it takes for the server to
reply (owing to the huge number of entries for the m2m field), I guess
this really isn't worth fixing if it's more involved than a simple
check. Ah well.

Thanks,
Chris

On Nov 25, 7:07 pm, Venkatraman S  wrote:
> On Fri, Nov 26, 2010 at 6:30 AM, Chris Tandiono 
> wrote:
>
> > How can I get the date field to show up in the admin interface?
>
> Couple of checks:
> - have you defined any custom forms for admin?
> - Do the field names match properly?
>
> A good practice generally is : do a 'sqlall' before you make the change in
> your models.py and then again do the same after mod'ing your models.py file.
> Do a diff between the two output sqlall files.
>
> $python manage.py sqlall > before.txt
> $vim ...models.py
> $python manage.py sqlall > after.txt
>
> -V-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Weird problem after schema change

2010-11-25 Thread Chris Tandiono
Hi,

I'm using sqlite3 and django-evolution (and sometimes manual ALTER TABLE 
commands) for this website I'm making. Recently I added a new date field to one 
of my models, but it's not showing up in the admin interface. (I'm also having 
a problem in which the admin interface is taking taking a long time to load, 
but I think that's because my model has a ManyToMany field to a model with a 
lot of rows in the table.) How can I get the date field to show up in the admin 
interface?

Thanks,
Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Issue uploading photos through the admin. PIL issue.

2010-11-22 Thread Chris
Opps, Just solved my own question.

python-dev is required which I had installed.

I found a package called pillow which seems to take care of the issue
that I was having.



On Nov 22, 2:07 pm, Chris  wrote:
> I am having an issue with uploading photos through the admin. I get
> this error: "Upload a valid image. The file you uploaded was either
> not an image or a corrupted image."  I am using ubuntu 10.04, python
> 26, virtualenv, and and pip. Is there a known issue with installng pil
> through pip + virtualenv?
>
> Any Ideas?
>
> Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Issue uploading photos through the admin. PIL issue.

2010-11-22 Thread Chris
I am having an issue with uploading photos through the admin. I get
this error: "Upload a valid image. The file you uploaded was either
not an image or a corrupted image."  I am using ubuntu 10.04, python
26, virtualenv, and and pip. Is there a known issue with installng pil
through pip + virtualenv?

Any Ideas?

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to join a search on user and user profile

2010-11-22 Thread Chris Lawlor
You should be able to do something like:

UserProfile.objects.filter(gender='female',
user__email='some...@mail.com')

Note the double underscore notation, which let's you access attributes
of the related model. This example assumes that UserProfile has a FK
field to User which is named 'user'.

On Nov 21, 10:36 pm, Rogério Carrasqueira
 wrote:
> Hello Folks!
>
> I'm working on my system that has 2 classes to work with user managemet:
> User and UserProfile, and I would like to make on admin an unified search.
> For example I would like to find a user by e-mail at User class and all User
> that is female or something like that. So, Is there anyway to work on this
> direction?
>
> Thanks
>
> Rogério Carrasqueira
>
> ---
> e-mail: rogerio.carrasque...@gmail.com
> skype: rgcarrasqueira
> MSN: rcarrasque...@hotmail.com
> ICQ: 50525616
> Tel.:(11) 7805-0074

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: help with django comments

2010-11-07 Thread Chris Lawlor

Assuming your app is named 'gallery' with a model named 'photo', I
believe the call should be:

{% get_comment_count for gallery.photo as comment_count %}


On Nov 6, 5:12 pm, Bobby Roberts  wrote:
> howdy -
>
> i'm trying to use comments on my site as follows:
>
> {% get_comment_count for galleryphoto as comment_count %}
>
> this generates the following error:
>
> Caught AttributeError while rendering: 'str' object has no attribute
> '_meta'
>
> any idea what this error means?
>
> I looked in /admin and under comments and in objects, i see "gallery
> photo" (with a space).
>
> when i try to use:
>
> {% get_comment_count for gallery photo as comment_count %}   <<< note
> the space in gallery photo
>
> I get this err:
>
> Third argument in u'get_comment_count' must be in the format
> 'app.model'
>
> any help is appreciated on how to address this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: moving from Postgres to MySQL

2010-10-22 Thread Chris Withers

On 21/10/2010 15:40, ringemup wrote:

MySQL has a tool (mysqldump) that will output the contents of an
entire database to a SQL file that can then be loaded directly into
another database.  Does Postgres not have anything analogous?


Sure, pg_dumpall. Now, what're the chances of the SQL that spits out 
being parsed correctly by MySQL without complaint? ;-)


Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: moving from Postgres to MySQL

2010-10-21 Thread Chris Withers

On 21/10/2010 14:48, David De La Harpe Golden wrote:

On 21/10/10 13:31, Chris Withers wrote:


...which is a little odd, given that the file was created by 'dumpdata'.
Any ideas?


Do you see any genuine wierdness in the format of any stringified
datetimes in the dumped json? Yes I know you've got 132 megs, but I
don't mean check totally manually, just do something like (untested):


...bt, why would dumpdata dump out something invalid?


I'm on Django 1.1...


Perhaps you could try a different approach: using django 1.2's multiple
database connections to do a live-live transfer,


What does one of these look like?
Is this going to involve me writing loads of for-loop-ish code or is 
there some sane tool?


Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: moving from Postgres to MySQL

2010-10-21 Thread Chris Withers

On 21/10/2010 14:06, Jeff Green wrote:

When I was using loaddata I found out that if I did not have a True or
False value for any boolean fields, I would have an issue loading the
data. Once, I set the value for any records to True or False I was
successfully able to use loaddata. Hope that helps


What does this have to do with datetimes?
How would I do this on a 200Mb text file?

Anyone know how to get loaddata to be a bit more explicit about where 
the failure was?


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: moving from Postgres to MySQL

2010-10-21 Thread Chris Withers

On 11/10/2010 14:03, Shawn Milochik wrote:

One way would be to use the dumpdata command to export everything, change your 
settings to point to the new database, then loaddata to restore.


Okay, so I'm using buildout and djangorecipe for my deployment.
On the postgres-backed server, I did:

bin/django dumpdata > logs.json

This took about 20 minutes and gave me a 132Mb file.

On the mysql-backed server, I did:

bin/django syncdb (and said no to creating a new user)
bin/django loaddata logs.json

This blew up fairly quickly with:

Installing json fixture 'logs' from absolute path.
Problem installing fixture 'logs.json': Traceback (most recent call last):
  File "django/django/core/management/commands/loaddata.py", line 150, 
in handle

for obj in objects:
  File "django/django/core/serializers/json.py", line 41, in Deserializer
for obj in PythonDeserializer(simplejson.load(stream)):
  File "django/django/core/serializers/python.py", line 101, in 
Deserializer

data[field.name] = field.to_python(field_value)
  File "django/django/db/models/fields/__init__.py", line 565, in to_python
_('Enter a valid date/time in -MM-DD HH:MM[:ss[.uu]] format.'))
ValidationError: Enter a valid date/time in -MM-DD 
HH:MM[:ss[.uu]] format.


...which is a little odd, given that the file was created by 'dumpdata'.
Any ideas?

I'm on Django 1.1...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to launch home page from urls.py?

2010-10-13 Thread Chris Boyd
Thank you Rob!

> {'template': 'index.html'}

But in that case I have to use Django template file, while my home page is
built with Pyjamas (http://pyjs.org/).

Can I use a Django urlpattern to launch any HTML file, not just Django
tempalte file?

Thank you,
Chris


On Wed, Oct 13, 2010 at 9:46 AM, Robbington wrote:

> Hi Chris,
>
> I use
>
>
> urlpatterns = patterns('django.views.generic.simple',
> (r'^$', 'direct_to_template',{'template': 'index.html'}),
>
> )
>
> Where template is the defined template directory in my settings.py
>
> Seems a better way to me, as then if you want to expand your site you
> can just incorperate django's templating language.
>
> Rob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to launch home page from urls.py?

2010-10-13 Thread Chris Boyd
Thank you for your response, Jonathan!

> I believe that the regular expression you're looking for is just "( r'^$',
...),"

Yes, that is right. "a.b.com" will be accepted and the control transfered,
but the problem is that I cannot provide the remaining part of the URI,
specifically "/winapp/HomePage.html <http://a.b.com/winapp/HomePage.html>"
in order to launch the home page. { 'document_root': 'winapp' } provides
only the folder, but I need to pass the sub-folder ("winapp") and the
filename ("HomePage.html").

I am not sure if there is a predefined key (similar to 'document_root') that
can be used to pass the file name?

I tried the following but nothing worked...

( r'^$', 'django.views.static.serve', { 'document_root': INSTALLATION_PATH +
'winapp' } ),

or

( r'^$', LandingPage ),

or

( r'^$', 'redirect_to', { 'url' : '/home/winapp/HomePage.html' } ),

or

( r'^$', '/home/winapp/HomePage.html' ),

Any ideas?

Thanks,
Chris


2010/10/13 Jonathan Barratt 

>
> On 13 ?.?. 2010, at 7:57, Chris wrote:
>
> > Hello,
> >
> > Currently in my urls.py I have "( r'^winapp/(?P.*)$',
> > 'django.views.static.serve', { 'document_root': 'winapp' } )," and I
> > can launch my home pahe by pointing my browser to something like
> > "a.b.com/winapp/HomePage.html".
> >
> > I have gone through the documentation and a couple of books, but I
> > cannot figure out how to launch "HomePage.html" by using just
> > "a.b.com".
>
> I believe that the regular expression you're looking for is just "( r'^$',
> ...),"
>
> Hth,
> Jonathan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: HTTP load testing tools?

2010-10-13 Thread Chris Withers

On 13/10/2010 09:17, Chris Withers wrote:

I hope this is still on topic, but what tool sets do people around here
use for doing load testing of Django projects?


Thanks for the answers...

...now to ask the question in a different way again ;-)

Anyone recommend any load testing services, consultancies, etc?
This sounds like the kind of thing that could/should be done in the cloud...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to launch home page from urls.py?

2010-10-13 Thread Chris
Hello,

Currently in my urls.py I have "( r'^winapp/(?P.*)$',
'django.views.static.serve', { 'document_root': 'winapp' } )," and I
can launch my home pahe by pointing my browser to something like
"a.b.com/winapp/HomePage.html".

I have gone through the documentation and a couple of books, but I
cannot figure out how to launch "HomePage.html" by using just
"a.b.com".

Any help is highly appreciated!

Thank you,
Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



HTTP load testing tools?

2010-10-13 Thread Chris Withers

Hey all,

I hope this is still on topic, but what tool sets do people around here 
use for doing load testing of Django projects?


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



moving from Postgres to MySQL

2010-10-11 Thread Chris Withers

Hi All,

I have an existing Django app with lots of data in it. For reasons 
beyond my control, this app needs to move from Postgres to MySQL.


What's the best way of going doing this?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: apache reload

2010-10-04 Thread Chris Lawlor
One approach is to set "MaxRequestsPerChild" to one, basically forcing
the server to reload on every request. Probably not the most efficient
way to accomplish this, but almost certainly the most simple to
implement.

On Oct 3, 5:39 pm, Олег Корсак 
wrote:
> Hello. I'm using mod_wsgi 3.3 + apache 2.2.16 on Gentoo Linux box.
> Is it possible to make apache kinda "reload"/"re-read"/"re-compile"
> python files from my django code every time they are changed?
>
> Thanks
>
>  signature.asc
> < 1KViewDownload

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: newbie question

2010-10-04 Thread Chris Lawlor
Also, one way to integrate scripts like this is to write them as
django management commands, so you can run them as 'python manage.py
yourcommand'. Management commands are pretty well documented in the
django docs, you should have no trouble finding enough info to get
started.


Again, good luck

Chris Lawlor

On Oct 4, 3:29 am, Martin Melin  wrote:
> On Mon, Oct 4, 2010 at 8:25 AM, mark jason  wrote:
> > hi
> > I am quite new to django ..I  have written a web app that takes user
> > input  and adds  customer details to db.
> > I store customer name,email ,a datetime value for each customer.
>
> > When the application starts ,I want a utility program to check the db
> > and if system datetime matches the datetime value stored for each
> > customer, an email is sent to the customer.
>
> > My doubt is ,where and how should I put the db checking and email
> > sending event logic.Should it be when the webserver starts(at python
> > manage.py runserver) ?If so ,where do I put the call to
> > check_db(),send_email() etc
>
> > I know it is a silly one,but please understand that I am a newcomer to
> > django and python..and programming in general
>
> > thanks and hoping for guidance
> > mark
>
> I assume the functionality you're after is that a specific user should
> receive an email as close to the datetime in their profile as
> possible?
>
> In that case, you don't want to run this only at application start.
> Generally it is not recommended to do anything at start, because
> depending on your environment it can be kind of undefined when
> "application start" actually occurs. "python manage.py runserver" is
> the so-called development server, and you should not rely on using it
> in production (when the app is on a server, not your local computer)
>
> A common way to solve problems like the one you're describing is to
> have a standalone script that runs periodically, triggered by cron.
>
> For info on writing scripts that have access to your Django project's
> models etc., have a look at Google's results for "django crontab" or
> similar.
>
> Good luck!
>
> Best regards,
> Martin Melin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Help Reading data from an uploaded CSV

2010-09-30 Thread Chris McComas
I have this code:

http://dpaste.com/250981/

The file is uploading properly, but it is not creating any entries in
my Pharmcas table, it's worked before, last spring when we used it
last, but right now it's not working? It uploads and saves the file as
it should, but then doesn't do any of the creating of entries in the
table?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sql query: how to

2010-09-27 Thread chris hendrix
yeah i was looking at something like that... actually let me correct 
what i'm needing to do:


select year(fieldname) as pubyear from table order by year(fieldname) asc




On 09/27/2010 01:15 AM, akaariai wrote:

The most efficient? Exactly that using raw SQL. I think something
along the following will also work:
Foo.objects.only('fieldname').value_list().distinct().order_by('fieldname').

  - Anssi

On Sep 27, 5:49 am, Bobby Roberts  wrote:
   

what is the most efficient way to do the following sql command in
django?

select distinct fieldname from table order by fieldname
 
   


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Subclassing User class or User class "profiles" recommended for extra attributes?

2010-09-20 Thread Chris Seberino
Adding extra attributes to User classes seems to be handled originally
by a "profiles".

A new way seems to be to subclass the User class.

One problem with the shiny new way is that lots of code is written to
handle User classes instead of subclasses.  The suggested way to fix
this is nontrivial.  You must write low level code to return a
subclass every time a User class is asked for.

Do most people still use profiles or is there an easier to to manage
sublassing User classes now?

Thanks!

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Strange unit test / OAuth Issue

2010-09-09 Thread Chris
Awh yes thank you for the tip.

After removing the incorrect versions and installing the correct ones,
I ran a simple md5 checksum to make sure that both my local dev and
prod versions match:

from oauth import oauth
from md5 import md5
print "You are using version: ", oauth.VERSION
filename = oauth.__file__[:-1]
print "Your OAuth file is located here: ", filename
checksum = md5(open(filename, "rb").read()).hexdigest()
print "Your OAuth checksum is: ", checksum


On Sep 7, 1:39 pm, Bill Freeman  wrote:
> Why not check which version of oauth you have in each place?
>
> Even if there isn't a usable version indicator in the library, you could
> generate a file containing the chacksums of all the py files, sort it, and
> compare it.
>
> On Tue, Sep 7, 2010 at 4:46 AM, Chris  wrote:
> > So I wrote some django unit tests for an app that uses OAuth and I ran
> > into this strange issue when attempting to set my verifier:
>
> > On my local dev machine it likes me to set my verifier like so:
> > token.set_verifier(verifier)
>
> > On my production machine it like me to set my verifier like so:
> > oauth_request = oauth.OAuthRequest.from_consumer_and_token(
> >    self.apicall.consumer,
> >    token=token,
> >    verifier=verifier,
> >    http_url=self.apicall.access_token_url
> > )
>
> > Both my dev machine and production machine can't agree on which way
> > they would like to set the verifier. If I perform both methods, then
> > both dev and production seem to be happy!  Why is this? Could I have a
> > slightly different version of oauth on both the machines?
>
> > Here is the full snippet of code that sets the verifier and makes the
> > access token request:
>
> >        verifier = "zNd4KsqnL9"
> >       # Dev likes it this way
> >        token.set_verifier(verifier)
>
> >        oauth_request = oauth.OAuthRequest.from_consumer_and_token(
> >            self.apicall.consumer,
> >            token=token,
> >            # prod likes it this way
> >            verifier=verifier,
> >            http_url=self.apicall.access_token_url
> >        )
> >        oauth_request.sign_request(self.apicall.signature_method,
> >            self.apicall.consumer, token
> >        )
> >        params = oauth_request.parameters
> >        response = self.client.get(self.apicall.access_token_url,
> > params)
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Strange unit test / OAuth Issue

2010-09-07 Thread Chris
So I wrote some django unit tests for an app that uses OAuth and I ran
into this strange issue when attempting to set my verifier:

On my local dev machine it likes me to set my verifier like so:
token.set_verifier(verifier)

On my production machine it like me to set my verifier like so:
oauth_request = oauth.OAuthRequest.from_consumer_and_token(
self.apicall.consumer,
token=token,
verifier=verifier,
http_url=self.apicall.access_token_url
)

Both my dev machine and production machine can't agree on which way
they would like to set the verifier. If I perform both methods, then
both dev and production seem to be happy!  Why is this? Could I have a
slightly different version of oauth on both the machines?

Here is the full snippet of code that sets the verifier and makes the
access token request:

verifier = "zNd4KsqnL9"
   # Dev likes it this way
token.set_verifier(verifier)

oauth_request = oauth.OAuthRequest.from_consumer_and_token(
self.apicall.consumer,
token=token,
# prod likes it this way
verifier=verifier,
http_url=self.apicall.access_token_url
)
oauth_request.sign_request(self.apicall.signature_method,
self.apicall.consumer, token
)
params = oauth_request.parameters
response = self.client.get(self.apicall.access_token_url,
params)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: project management app

2010-08-17 Thread chris hendrix
yeah i couldn't get it installed either.  I'm wondering if the project 
was abandoned or something.  I don't have time to contribute anything in 
regard to programming at the moment due to starting up a web design 
firm.  However, i'd love to help you flesh out ideas or be a beta tester 
for you... keep me posted!



chris

On 08/17/2010 04:35 PM, tiemonster wrote:

I was unable to get the code working. I'm developing a project
management application for Django if you're interested in
contributing.

On Aug 16, 2:27 pm, Bobby Roberts  wrote:
   

hi all.

I've foundhttp://code.google.com/p/django-project-management/out
there as a project management app but have yet to install it and see
what all it can do.  Has anyone installed this and do you have an
opinion on it?  Is there anything else out there for project
management?
 
   


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Need help setting up dynamic options for select (drop down) box of form.

2010-08-03 Thread Chris Seberino


On Aug 3, 3:29 am, Daniel Roseman  wrote:
> Anyway, I suspect the cause is setting the widget.

I found my bug.  To convert a textbox to a drop down box, it isn't
enough to reset the widget and choices settings.  It is also necessary
of course to reset the field type from a CharField to a ChoicesField.

All the best,

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Need help setting up dynamic options for select (drop down) box of form.

2010-08-02 Thread Chris Seberino
I'm trying to make the options of a particular drop down box be
determined at runtime.

I added a __init__ constructor to my django.forms.Form subclass as
follows...

def __init__(self,
   data= None,
   error_class =
django.forms.util.ErrorList,
   manage_sites_domain = None):
 
"""
 
constructor
"""

super(InputPostsForm, self).__init__(data,
 error_class =
error_class)
if manage_sites_domain:
domain = manage_sites_domain
site   = SITE.objects.get(domain = domain)
categories = CATEGORY.objects.filter(site =
site)
choices= [2 * (e.name,) for e in categories]
pc = self.fields["post_category"]
pc.widget  = SELECT()
pc.choices = choices

I printed the choices list to verify the list contains a tuple with 2
strings.

When I view the form in a browser I see a drop down box with NO
choices.  Or rather, a blank choice.

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



*Unnecessary* instances of HTML escape sequences like λ ?

2010-07-30 Thread Chris Seberino
I understand the need for web pages to denote the 5 HTML special
characters >, &, <, ', and " with alternate representations like
".

(These 5 are the *only* special characters in HTML right?)

What I don't understand is why an HTML page encoded with UTF-8 would
use this &#...; format for other *NON* special characters as well.  It
is unnecessary for anything else right?

(By the way, this reason this came up is I pasted some text from
OpenOffice into a Django form that was pushed to a WordPress site.  I
noticed a zillion of these &#...; all over the place.  Most seemed
unnecessary since UTF-8 is already powerful enough to handle all types
of chars with addition of special treatment for &, <, >, ' and ".  I'm
not sure what part of the process added these HTML entities OpenOffice
-> Django -> WordPress)

Thanks!

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-21 Thread Chris Seberino


On Jul 17, 11:16 am, Justin Myers  wrote:

> or just put that one line (with a semicolon at the end, since it's
> missing one) in a 

Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-16 Thread Chris Seberino
On Jul 15, 3:57 am, Oleg Lomaka  wrote:
> First without javascript. You cat check URL of HttpRequest and if it is 
> without
#anchor element, then send redirect to the same URL with #anchor.

Yes redirection is a great non-Javascript way to do this.

Is there ANY way to preserve the old form data through the
redirection?

(Imagine an invalid form that gets kicked back to the user.If I do
a redirection must I lose the prepopulated data?)

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-16 Thread Chris Seberino
On Jul 15, 3:44 am, Daniel Roseman  wrote:
>      window.location = window.location + '#whatever'

I added that code to script element in head and it didn't work.

I have a TinyMCE javascript editor that gets run too.  I don't know if
that is conflicting or if there is something else I need to do to make
it work?

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How can view tweak response object to go to a specific *anchor* on the template?

2010-07-14 Thread Chris Seberino

How can a view tweak the response object so that client sees a
specific anchor  instead of the top of the page?

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
This worked:

import datetime
Then, use 'datetime.datetime.now()' instead of 'datetime.now()'

Thanks guys!

On Jul 14, 11:57 am, Subhranath Chunder  wrote:
> How did u import the datetime module?
> If you did:
>
> a>
> import datetime
> Then, use 'datetime.datetime.now()' instead of 'datetime.now()'
>
> b>
> from datetime import datetime
> Then 'datetime.now()' should work correctly.
>
> Thanks,
> Subhranath Chunder.
>
> On Wed, Jul 14, 2010 at 9:13 PM, Chris McComas wrote:
>
>
>
> > This is my model, I'm trying to set it so that if the game is in the
> > future, based on the field date, then to return True, if not return
> > False.
>
> >http://dpaste.com/218111/
>
> > I am importing datetime in my models.py but for some reason it's
> > giving me nothing. I tried displaying future and nothing shows up?
> > What have I done wrong?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
I'm using it in my template...

Basically this http://dpaste.com/218114/

Mainly I want to use it for the {% if %} but I tried to just show it
was well and still nothing...



On Jul 14, 11:49 am, Daniel Roseman  wrote:
> On Jul 14, 4:43 pm, Chris McComas  wrote:
>
> > This is my model, I'm trying to set it so that if the game is in the
> > future, based on the field date, then to return True, if not return
> > False.
>
> >http://dpaste.com/218111/
>
> > I am importing datetime in my models.py but for some reason it's
> > giving me nothing. I tried displaying future and nothing shows up?
> > What have I done wrong?
>
> How/where are you calling this method?
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Comparing DateTimeField to datetime.now()

2010-07-14 Thread Chris McComas
This is my model, I'm trying to set it so that if the game is in the
future, based on the field date, then to return True, if not return
False.

http://dpaste.com/218111/

I am importing datetime in my models.py but for some reason it's
giving me nothing. I tried displaying future and nothing shows up?
What have I done wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: www.djangoproject.com

2010-07-14 Thread Chris Lawlor
Nick, thank you so much for figuring this out!!

On Jul 8, 11:12 am, Nick Raptis  wrote:

> In firefox, check your preffered language settings, in the content tab.
>
> If there is a non-standard value there (perhaps "/etc/locale/prefs.conf"
> or something) instead of a locale like en-US,
> some django pages won't ever display.
>
> Nick
>
> On 07/08/2010 04:11 PM, eon wrote:
>
> > Same for me. The problem is in the firefox profile (maybe due to the
> > switch from 3.5 to 3.6 ?)
>
> > Start-up with a new profile (backport plugins, bookmarks argh...)
> > resolves the issue
>
> > On 5 juil, 20:52, Andi  wrote:
>
> >> On Jul 2, 10:44 pm, Bill Freeman  wrote:
>
> >>> What might be of help is adding the IP address to /etc/hosts, if you are
> >>> on linux.
>
> >> I have the same problem regarding djangoproject.com (Firefox 3.6.6 on
> >> Ubuntu).  Everything works but Firefox using my default profile: host
> >> and nslookup succeed in resolving the domain name.  Adding the IP to /
> >> etc/hosts or accessing the IP address directly in firefox doesn't
> >> help.  Opera, chromium, arora, w3m, elinks, lynx and konqueror are not
> >> affected.  Firefoxes on other hosts within the same LAN can connect to
> >> djangoproject.com without a problem.  Disabling all add-ons living in
> >> my Firefox doesn't have an effect -- but starting with a fresh profile
> >> does: djangoproject.com loads successfully.
>
> >> It's a very strange problem, because there is no problem with the
> >> other thousands of websites I've visited during the last days.  It's
> >> the combination djangoproject.com + my main Firefox profile which
> >> produces the problem exclusively.
>
> >> --
> >> Andi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help Converting a Query getting one result using .filter() to .get()

2010-07-13 Thread Chris McComas
Sorry, I should've said what I'm using it for...

Here's my models http://dpaste.com/217686/

The query above I just want to get the next/upcoming game in the
database, which I display on the sidebar of the front page. What I am
trying to do, is also get ALL other entries from the database, in a
separate query where sport=sport and opponent=opponent to figure out
the historical Win/Loss record between the teams?



On Jul 12, 8:15 pm, John M  wrote:
> Why does it matter?
>
> You could just say next_game[0] instead.
>
> J
>
> On Jul 12, 4:28 pm, Chris McComas  wrote:
>
>
>
> > I have this query, trying to get the next game in the future.
>
> > today = datetime.datetime.now()
> > next_game = Game.objects.filter(date__gt=today).order_by('date')[:1]
>
> > I need to use .get() if possible, instead of .filter() how can I do
> > this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Streaming File Uploads with Lighttpd+Django

2010-07-12 Thread Chris
Nevermind, I finally found my answer after hours of searching in this
thread:
http://forum.lighttpd.net/topic/1142

On Jul 12, 11:08 pm, Chris  wrote:
> Hi all,
>
> I just recently deployed my django site from the included development
> webserver to a production server with lighttpd.  I'm new to both
> Lighttpd and Django so forgive my ignorance.  When using the
> development webserver, I can see streaming files in the tmp directory
> grow if the uploaded file is >2.5mb as Django says.  However, on my
> lighttpd configuration, it seems to keep the file in memory, because
> it doesn't show the temporary file in the tmp directory until the
> entire file has been uploaded.  This will be a problem as I'm planning
> on uploading files anywhere from 5mb- 5gb.  I'm not sure if there is
> something I need to set, or if lighty is streaming the upload but just
> to a different directory.
>
> Also, if anyone has any links or advice on large file uploads, please
> send them over...I'd love to know if there is a better approach.
>
> Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Streaming File Uploads with Lighttpd+Django

2010-07-12 Thread Chris
Hi all,

I just recently deployed my django site from the included development
webserver to a production server with lighttpd.  I'm new to both
Lighttpd and Django so forgive my ignorance.  When using the
development webserver, I can see streaming files in the tmp directory
grow if the uploaded file is >2.5mb as Django says.  However, on my
lighttpd configuration, it seems to keep the file in memory, because
it doesn't show the temporary file in the tmp directory until the
entire file has been uploaded.  This will be a problem as I'm planning
on uploading files anywhere from 5mb- 5gb.  I'm not sure if there is
something I need to set, or if lighty is streaming the upload but just
to a different directory.

Also, if anyone has any links or advice on large file uploads, please
send them over...I'd love to know if there is a better approach.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Help Converting a Query getting one result using .filter() to .get()

2010-07-12 Thread Chris McComas
I have this query, trying to get the next game in the future.

today = datetime.datetime.now()
next_game = Game.objects.filter(date__gt=today).order_by('date')[:1]

I need to use .get() if possible, instead of .filter() how can I do
this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



"SESSION_SAVE_EVERY_REQUEST = True" performance hog? Any other cons?

2010-07-10 Thread Chris Seberino
SESSION_SAVE_EVERY_REQUEST = True
(in settings.py)

seems to avoid a lot of potential bugs from forgetting to set
request.session.modified = True when necessary.

Is this a serious performance problem?  If not, I would think this
would be a good *default* value for Django no?

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: What causes request.session to be erased?...When you go to different view?

2010-07-10 Thread Chris Seberino
Wow beautiful.  Thanks.  I needed that.

cs

On Jul 10, 12:14 am, Javier Guerra Giraldez 
wrote:
> On Fri, Jul 9, 2010 at 11:36 PM, Chris Seberino  wrote:
> > elif form.is_valid():
> >        ...
> >        request.session["posts"].append(form.cleaned_data)
> >        
>
> > I noticed that everytime I revisit this form and rerun this view, the
> > request.session["posts"] lists gets blown away and is empty again!?!?
>
> > Am I misunderstanding something about requests and sessions?
>
> from the docs 
> (http://docs.djangoproject.com/en/1.2/topics/http/sessions/#when-sessi...
>
>   # Gotcha: Session is NOT modified, because this alters
>   # request.session['foo'] instead of request.session.
>   request.session['foo']['bar'] = 'baz'
>   In the last case of the above example, we can tell the session
> object explicitly that it has been modified by setting the modified
> attribute on the session object:
>
>   request.session.modified = True
>
> that's exactly your case.  the session object is saved automatically
> only when it's marked as modified.  but when you modify an object
> inside the session and not the session itself; it doesn't gets
> notified of the change, so you have to tell it explicitly.
>
> --
> Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



What causes request.session to be erased?...When you go to different view?

2010-07-09 Thread Chris Seberino
Ever time a web page is visited, a view is called and a NEW request
object is passed in right?

Then if I'm not mistaken, it appears you can't maintain
request.session when you visit a new web page and a new view because a
NEW request object is passed in to the new view right?



My personal code visits a certain form multiple times to create new
"posts".  I was trying to collect them in a list I store in the
session as follows

...
elif form.is_valid():
...
request.session["posts"].append(form.cleaned_data)


I noticed that everytime I revisit this form and rerun this view, the
request.session["posts"] lists gets blown away and is empty again!?!?


Am I misunderstanding something about requests and sessions?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [Offtopic] Design introduction

2010-07-08 Thread Chris Czub
Much like programming, it will come from experience. Practice a lot. You'll
make a lot of things you aren't happy with, probably like your first bits of
code :) Try to imitate things you like, and see the techniques they use to
create cool designs. It, like anything else worth doing, will be easier with
experience. The best way is to just do. See if you have any artistic friends
that can give feedback on what you're creating. Try to identify what colors
work well together(a site like colourlovers.com is nice for finding color
schemes) and work with those.

On Thu, Jul 8, 2010 at 10:27 AM, Matias  wrote:

> Sorry for this completely offtopic question.
>
> I'm a systems administrator with programming experience (mostly python and
> C) and I love web applications design/programming and I'm pretty good with
> html, javascript, css, etc... but I have a really weak point when it comes
> to "images" desing. I mean, I'd love to learn how to do images like this:
> http://www.freecsstemplates.org/previews/solutions/images/img01.gif
>
> (from the template http://www.freecsstemplates.org/preview/solutions/)
>
> I understand the basics, and I use quite frequently Gimp, but this is not
> like coding, when you code, most of the times it is easy to understand what
> is happenning (except if the code you are reading is perl :-P ) and thus,
> you can learn but I still can't "read" images I see out there, so, I
> guess there should be any learning path for this also or maybe is that just
> the creative half of my brain is missing.
>
> Would you recommend any book? any website? or some other way to learn to do
> "nice 3d looking menus, buttons"..etc?
>
> Thanks for your help, and sorry for the offtopic, but I didn't find a
> better place to ask this. (didn't look for a lot also...)
>
>
> Thanks!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: contrib.auth.views - n00b question

2010-07-07 Thread Chris Lawlor
;/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> _render
>   167.         return self.nodelist.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> render
>   796.                 bits.append(self.render_node(node, context))
> File "/usr/lib/python2.6/dist-packages/django/template/debug.py" in
> render_node
>   72.             result = node.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/loader_tags.py"
> in render
>   125.         return compiled_parent._render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> _render
>   167.         return self.nodelist.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> render
>   796.                 bits.append(self.render_node(node, context))
> File "/usr/lib/python2.6/dist-packages/django/template/debug.py" in
> render_node
>   72.             result = node.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/defaulttags.py"
> in render
>   252.             return self.nodelist_true.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> render
>   796.                 bits.append(self.render_node(node, context))
> File "/usr/lib/python2.6/dist-packages/django/template/debug.py" in
> render_node
>   72.             result = node.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/defaulttags.py"
> in render
>   252.             return self.nodelist_true.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> render
>   796.                 bits.append(self.render_node(node, context))
> File "/usr/lib/python2.6/dist-packages/django/template/debug.py" in
> render_node
>   72.             result = node.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/loader_tags.py"
> in render
>   62.             result = block.nodelist.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/__init__.py" in
> render
>   796.                 bits.append(self.render_node(node, context))
> File "/usr/lib/python2.6/dist-packages/django/template/debug.py" in
> render_node
>   72.             result = node.render(context)
> File "/usr/lib/python2.6/dist-packages/django/template/defaulttags.py"
> in render
>   367.             url = reverse(self.view_name, args=args,
> kwargs=kwargs, current_app=context.current_app)
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> reverse
>   356.             *args, **kwargs)))
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> reverse
>   277.         possibilities = self.reverse_dict.getlist(lookup_view)
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _get_reverse_dict
>   199.             self._populate()
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _populate
>   179.                     for name in pattern.reverse_dict:
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _get_reverse_dict
>   199.             self._populate()
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _populate
>   168.         for pattern in reversed(self.url_patterns):
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _get_url_patterns
>   249.         patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
> File "/usr/lib/python2.6/dist-packages/django/core/urlresolvers.py" in
> _get_urlconf_module
>   244.             self._urlconf_module =
> import_module(self.urlconf_name)
> File "/usr/lib/python2.6/dist-packages/django/utils/importlib.py" in
> import_module
>   35.     __import__(name)
> File "/django/projects/huntgather/registration/urls.py" in 
>   14. from gather import login,logout
>
> Exception Type: TemplateSyntaxError at /admin/
> Exception Value: Caught ImportError while rendering: cannot import
> name login
>
> On Jul 6, 9:24 am, Chris Lawlor  wrote:> You probably 
> don't want to reference the login view to /accounts. You
> > probably mean to do this:
>
> > (r'^accounts/', include ('django.contrib.auth.urls'),
>
> > That will map /accounts/login to django.contrib.views.login, /accounts/
> > logout to django.contrib.views.logout, etc.
>
> > In general, when using an app, you'll add a line to your base URLConf
> > that includes that app's urls module.
>
> > On Jul 6, 9:04 am, Tom Evans  wrote:
>
> > > On Tue, Jul 6, 2010 at 2:00 PM,reduxdj wrote:
> > > > Hi,
>
> > > > I have an issue where i am including contrib.auth into my URLs,
> > > > however, I get this error:
>
> > > > my url pattern:
>
> > > > (r'^accounts/', include('django.contrib.auth.views.login')),
>
> > > django.contrib.auth.views.login is a view, not a url pattern, so you
> > > don't include it, you reference it:
>
> > > (r'^accounts/', 'django.contrib.auth.views.login'),
>
> > > Cheers
>
> > > Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: contrib.auth.views - n00b question

2010-07-06 Thread Chris Lawlor
You probably don't want to reference the login view to /accounts. You
probably mean to do this:

(r'^accounts/', include ('django.contrib.auth.urls'),

That will map /accounts/login to django.contrib.views.login, /accounts/
logout to django.contrib.views.logout, etc.

In general, when using an app, you'll add a line to your base URLConf
that includes that app's urls module.

On Jul 6, 9:04 am, Tom Evans  wrote:
> On Tue, Jul 6, 2010 at 2:00 PM, reduxdj  wrote:
> > Hi,
>
> > I have an issue where i am including contrib.auth into my URLs,
> > however, I get this error:
>
> > my url pattern:
>
> > (r'^accounts/', include('django.contrib.auth.views.login')),
>
> django.contrib.auth.views.login is a view, not a url pattern, so you
> don't include it, you reference it:
>
> (r'^accounts/', 'django.contrib.auth.views.login'),
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How interate over just a slice of form fields in template? (I tried {% for e in form|slice:":5" %} )

2010-07-05 Thread Chris Seberino
How interate over just a slice of form fields in template?

I tried {% for e in form|slice:":5" %} but it appears the slice part
is just ignored.

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How set initial form field value in the view function?

2010-07-04 Thread Chris Seberino
How set initial form field value in the view function?

The initial keyword is great when defining a subclass of Form if you
the initial values is ALWAYS the same.

What if it varies?...I'm guessing I must set it in the view.

How set this initial value in the view?

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi sometimes gives error on first reload but not thereafter

2010-06-16 Thread Chris Seberino
On Jun 15, 6:42 pm, Graham Dumpleton 
wrote:

> This occurs when Apache is first reading HTTP headers for request and
> long before it hands it off to any Django application or even
> mod_wsgi.

Is there anything I can do about this?  I assume this means we should
pronounce the mod_wsgi setup I have good and not bother trying to use
your sample script after all like you discussed in previous email?

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi sometimes gives error on first reload but not thereafter

2010-06-15 Thread Chris Seberino
I found the Apache error for this mod_wsgi error that only appears the
first time I reload an app after restarting Apache

[Tue Jun 15 18:12:39 2010] [error] [client ] request
failed: error reading the headers, referer: http://

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi sometimes gives error on first reload but not thereafter

2010-06-15 Thread Chris Seberino
On Jun 14, 7:02 pm, Graham Dumpleton 
wrote:
 > Use WSGI script described in:
>
>  http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

In mod_wsgi's defense, remember that this error happens sporadically
and is NOT a showstopper as a reload makes it go away completely
(until a future restart).

I did look at that page a while back when we talked previously.  It
helped me get mod_wsgi working.  I'm not sure what you are asking me
to doDo you want me to use the exact script and send you the
output of the print statements?  Would my aforementioned error show up
in the Apache logs?  If and when I see it again I will look in the
Apache error.log for clues too.

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



mod_wsgi sometimes gives error on first reload but not thereafter

2010-06-14 Thread Chris Seberino
1. Restarting Apache+mod_wsgi
2. Clearing Firefox cache and
3. Visiting Django app URL

are all done often when debugging/developing a DJango app under Apache
+mod_wsgi.

I've noticed with mod_wsgi, I will *SOMETIMES* get an error after this
triad.

Reloading the Django URL makes it go away so it only appears on the
first visit to Django app.

I will see sometimes like "400 Bad Request" page in Firefox...

"""
Bad Request

Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.

er.com/set_up
"""

The DJango URL (I'm using Django auth) is
https://seoconquer.com/sign_in?next=/set_up

Any help greatly appreciated.

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



multiple databases -- database across sites?

2010-06-10 Thread chris
Hi there,

I have the following problem:

There is one django site, which consists of two apps, the data for
these apps are stored in a database.  Some of the models in one app
access models from the other app.

Now I want to create a new site (on the same server), which contains
new data for one of the apps, but needs to re-use and extend the data
from the second app (the first site will also continue to use the data
in this part).

I realized that Django 1.2.1 supports multiple databases, but I am
still not sure if this is possible and if yes, how it can be done.
Any help appreciated.

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Good idea to process form data in separate thread or process to avoid blocking? How?

2010-06-07 Thread Chris Seberino
I don't want Django site to block while form data is being processed.

What is easiest way to run a separate script in a separate thread or
process with form data as input parameters?

e.g. commands.getoutput("my_script arg1 arg2") or
   os.system("my_script arg1 arg2") <--- possible to run these in
separate thread or process easily so Django app doesn't have to wait
on it?  How?

Thanks!

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Issues running Djano app as Apache's www-data user with mod_wsgi.

2010-06-06 Thread Chris Seberino
My Django app runs great with Apache+mod_wsgi.
Apache now runs my Django app as user www-data.
This causes issues since my Django app is sitting in my non-root
user's $HOME directory.

Best solution seems to be to add my user and www-data to same group
and then put my Django app directory in that group.

Problem is that when I create **NEW** files they are NOT automatically
added to this new group!??!

Sound familiar?

Chris


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi can't find app to import..but I added path to wsgi file?!

2010-05-28 Thread Chris Seberino
On May 27, 6:56 pm, Graham Dumpleton 
wrote:
> You also need to add '/home/seb/MAIN/seoconquer'. Read:
>
>  http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

I tried both versions of the wsgi script on your blog. And I still get
this same error.

ImportError: No module named mvc

I think the problem is this line in settings.py where it can't find
seoconquer.mvc to load.

I printed the vars on your blog from withing my settings.py if that
helps...

__name__ =seoconquer.settings
__file__ =/home/seb/MAIN/seoconquer/settings.py
os.getcwd() =/home/www
os.curdir =.
sys.path =['/home/seb/MAIN', '/home/seb/MAIN/seoconquer',...etc.]
sys.modules.keys() =['django.utils.text', 'decimal',
'django.core.django',...etc.]
sys.modules.has_key('seoconquer') =True

Notice that both necessary paths are in sys.path?!?!!?

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi can't find app to import..but I added path to wsgi file?!

2010-05-27 Thread Chris Seberino
On May 27, 10:51 am, Nuno Maltez  wrote:
> > ImportError: No module named mvc
>
> What's the "mvc" module? Python can't seem to find it. Is it in your
> python path?

My project is called seoconquer.
My app is called mvc.
My absolute directory path to mvc is /home/seb/MAIN/seoconquer/mvc.

I have /home/seb/MAIN added to path in the wsgi file.  (See above.)

I'm trying to load the mvc app in my settings file with INSTALLED_APPS
= (, "seoconquer.mvc")

Here is my settings.py..

# Contains the configuration settings.

import os

DEBUG = True

DATABASE_NAME   = "seoconquer"
DATABASE_USER   = "seb"
DATABASE_ENGINE = "django.db.backends.mysql"
TEMPLATE_DIRS   = ("/home/seb/MAIN/seoconquer/mvc/views",)
ROOT_URLCONF= DATABASE_NAME + "." + "urls"
LOGIN_URL   = "sign_in"
INSTALLED_APPS  = ("django.contrib.auth",
   "django.contrib.contenttypes",
   "django.contrib.sessions",
   "seoconquer.mvc")

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi can't find app to import..but I added path to wsgi file?!

2010-05-27 Thread Chris Seberino

I fixed the path issue that was causing the spinning but now I'm back
to getting import errors even with __init__.py in my apache
directory.  Here is the exact error from Apache's error.log.

...
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]
_default = translation(settings.LANGUAGE_CODE)
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]   File "/
usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",
line 194, in translation
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]
default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]   File "/
usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py",
line 180, in _fetch
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130] app =
import_module(appname)
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]   File "/
usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in
import_module
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]
__import__(name)
[Thu May 27 10:18:18 2010] [error] [client 99.159.221.130]
ImportError: No module named mvc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi can't find app to import..but I added path to wsgi file?!

2010-05-27 Thread Chris Seberino
On May 25, 9:03 pm, Kenneth Gonsalves  wrote:
> you need to add the path to the *parent* directory of your project, and your
> project should have __init__.py in every folder where there are python files

Thanks.  I added __init__.py to an apache directory I created in my
project directory that includes the wsgi file.
Now Apache does NOT give me an error.  Rather, now Apache just spins
and spins in some infinite loop never loading my django web page!?!?

No errors appear in the Apache error.log because it just spins waiting
to finish something.



Here is my wsgi file.


import sys
sys.path.append("/home/seb/MAIN")

import django.core.handlers.wsgi
import os

os.environ["DJANGO_SETTINGS_MODULE"] = "seoconquer.settings"
application  =
django.core.handlers.wsgi.WSGIHandler()


Here is relevant part of my Apache config inside my vhosts..


WSGIDaemonProcess seoconquer.com threads=25
WSGIProcessGroup  seoconquer.com
 
WSGIScriptAlias   /
\
  /home/seb/MAIN/seoconquer/apache/
application.wsgi

Order Allow,Deny
Allow from All



Any help still greatly appreciated as always.

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



mod_wsgi can't find app to import..but I added path to wsgi file?!

2010-05-25 Thread Chris Seberino
I can successfully run a toy WSGI app with my Apache/mod_wsgi set up.

When I try to run my Django app with mod_wsgi it can't ever find the
modules to load and Apache's error.log gives ImportError's.

I tried adding paths to sys.path in the wsgi file.

Not what else to try.

cs

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: slow filtering by related and local fields, only on sqlite, not on postgres?

2010-05-23 Thread Chris Withers

Chris Withers wrote:

queryset = TicketStatus.objects.filter(active=True)
if user_id:
queryset = queryset.filter(owner=User.objects.get(id=user_id))
queryset = queryset.filter(ticket__event=event)
return list_detail.object_list(
request,
queryset = 
queryset.order_by('ticket__number').select_related('Ticket'),

template_name = 'tickets_list.html',
paginate_by = 50,
extra_context = dict(
events = events,
current_event_id = event.id,
users = users,
current_user_id = user_id
)
)

And it shows the culprit:

SELECT COUNT(*) FROM "tracker_ticketstatus" INNER JOIN "tracker_ticket" 
ON ("tracker_ticketstatus"."ticket_id" = "tracker_ticket"."id") WHERE 
("tracker_ticketstatus"."active" = True  AND 
"tracker_ticketstatus"."owner_id" = 1  AND "tracker_ticket"."event_id" = 
3 )

38.143


However, when I have exactly the same models on a postgres backend, 
everything is fine.


So, it's just slow on a sqlite backend, which is a shame as that's how I 
normally develop!


Any ideas?

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: filtering by related object causes query to grind to a halt

2010-05-23 Thread Chris Withers
Okay, so I noticed that it's the following code, and it's only when I 
filter on user *end* event:


Chris Withers wrote:

queryset = TicketStatus.objects.filter(active=True)
if user_id:
queryset = queryset.filter(owner=User.objects.get(id=user_id))
queryset = queryset.filter(ticket__event=event)
return list_detail.object_list(
request,
queryset = 
queryset.order_by('ticket__number').select_related('Ticket'),

template_name = 'tickets_list.html',
paginate_by = 50,
extra_context = dict(
events = events,
current_event_id = event.id,
users = users,
current_user_id = user_id
)
)


Here I added:

from django.db import connection
for query in connection.queries:
print query['sql']
print query['time']
print

And it shows the culprit:

SELECT COUNT(*) FROM "tracker_ticketstatus" INNER JOIN "tracker_ticket" 
ON ("tracker_ticketstatus"."ticket_id" = "tracker_ticket"."id") WHERE 
("tracker_ticketstatus"."active" = True  AND 
"tracker_ticketstatus"."owner_id" = 1  AND "tracker_ticket"."event_id" = 3 )

38.143

Why is this select being executed? Well, how can I find out what code is 
causing it?


Also, why is it so slow?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
   - http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



<    1   2   3   4   5   6   7   8   9   10   >