Re: File upload: how to validate file type

2009-03-29 Thread Torsten Bronger
Hallöchen! Torsten Bronger writes: > I'd like to ensure that people only upload PDF files, so the file > must start with "%PDF". If the file starts with something else, > the form must not validate. > > How do I do that? I though about a clean_... method which reads > the start of the file

Re: What hash algorithm does django auth use?

2009-03-29 Thread Malcolm Tredinnick
On Mon, 2009-03-30 at 12:50 +1100, Joshua Partogi wrote: > Hi all, > > I tried saving the password data with this function > > import hashlib > hashlib.md5( new_member.password ).hexdigest() > > but when I log in again with that password it doesnt work. A number of problems here. Firstly,

Re: Best Convension for dealing with variables needed in every view.

2009-03-29 Thread David Zhou
I've never really understood why the context processor list wasn't part of the default settings.py. But I've always just copied and pasted the complete list into settings. On Sun, Mar 29, 2009 at 7:40 PM, IanR wrote: > > So I see that I can easily create a

Re: What hash algorithm does django auth use?

2009-03-29 Thread David Zhou
On Sun, Mar 29, 2009 at 9:50 PM, Joshua Partogi wrote: > > I thought we're to use hexdigest ? > > Did I miss something here? You need to salt it: http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/models.py#L20 -- dz

What hash algorithm does django auth use?

2009-03-29 Thread Joshua Partogi
Hi all, I tried saving the password data with this function import hashlib hashlib.md5( new_member.password ).hexdigest() but when I log in again with that password it doesnt work. I thought we're to use hexdigest ? Did I miss something here? Thank you very much in advance -- If you can't

custom form in admin debugging confusion

2009-03-29 Thread felix
class ContactAdmin(Admin): form = EditContactForm EditContactForm has a save method that is never called by the Admin but its clean() function does get called 60 def clean(self): 61 import pdb; pdb.set_trace() my confusion is that due to the snakey admin code the

MySQL group_concat with aggregates

2009-03-29 Thread Matthew Somerville
Hi, I have the model described at http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany on which I have multiple rows in Membership with the same Person and Group (say they're a bit flaky, and leave and rejoin a few times ;) ). I wanted to print out a paginated list

Re: Max_num in formset

2009-03-29 Thread Malcolm Tredinnick
On Sun, 2009-03-29 at 18:01 -0400, Vitaly Babiy wrote: > Maybe I should have said why I ask. > > I have a formset that the formset can not submit more than certain > number of forms. I was not sure if max_num handles this or do I need > to do this with some custom validation? What happened

Re: If less than in template language

2009-03-29 Thread Robert
Sorry, but I really am relatively new to Django, and although I've been poking around for quite a while, I still just can't get that package to work. When I tried to install it inside of the contrib folder, and then add it to the 'installed applications' in the settings.py file, i kept on getting

Re: Best Convension for dealing with variables needed in every view.

2009-03-29 Thread IanR
So I see that I can easily create a context_processor to do this stuff for me. It says that these are the default context_processors. I can not find them in the settings.py, where is this located? (I grepped my whole project so it must be somewhere else) TEMPLATE_CONTEXT_PROCESSORS

Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Russell Keith-Magee
On Mon, Mar 30, 2009 at 1:42 AM, Rob Hudson wrote: > > Wow, that was a tricky one to track down... ... > I take it that gets interpreted as a single value tuple.  D'oh!  That It does, operator precedence notwithstanding (for example, a lambda expression returning a tuple

Best Convension for dealing with variables needed in every view.

2009-03-29 Thread IanR
I'm currently converting my website from PHP to Django. I've always loved python and all my backend code is in python. I figured that it might as well make the jump. So far so good, as everything has been very strait forward and a joy. It's definitely making web development fun again. I'm

Re: Can't import flup.server.fcgi

2009-03-29 Thread alec resnick
For others running into this problem, pulling from the django trunk and running with the most recent version fixed this problem for me. Thanks! -a. On Mar 19, 8:31 pm, coffeepunk wrote: > > This has been reported as ticket #10556 earlier today. It will be fixed > > in the

Re: Max_num in formset

2009-03-29 Thread Vitaly Babiy
Maybe I should have said why I ask. I have a formset that the formset can not submit more than certain number of forms. I was not sure if max_num handles this or do I need to do this with some custom validation? Vitaly Babiy On Sun, Mar 29, 2009 at 5:57 PM, Vitaly Babiy

Re: Problem with Field errors

2009-03-29 Thread Matthew Somerville
Jack Orenstein wrote: > On Mar 29, 2009, at 9:35 AM, Matthew Somerville wrote: >> For more information, see >> http://docs.djangoproject.com/en/dev/ref/forms/validation/ > > Thanks, that's really useful to know about. This works for most of > the additional validation I need to do, but

Max_num in formset

2009-03-29 Thread Vitaly Babiy
If the count of forms submit goes over the max_num shouldn't it raise and validation error? Thanks, Vitaly Babiy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send

Re: Howto create related objects in one shot?

2009-03-29 Thread Yaniv Haber
On Mar 23, 9:39 am, Malcolm Tredinnick wrote: > On Mon, 2009-03-23 at 00:18 -0700, Yaniv Haber wrote: > > On Mar 23, 1:41 am, Malcolm Tredinnick > > wrote: > > > On Sun, 2009-03-22 at 05:39 -0700, nivhab wrote: > > > > Hi, > > > > > I have

Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson
Wow, that was a tricky one to track down... After putting debug output in django/template/loaders/filesystem.py I saw that filepath was set to: '/Users/rob/git/anglers/anglers/templates/('book/ search_form.html',)' I back tracked that and found that I had a trailing comma in my view code:

Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson
On Sun, Mar 29, 2009 at 8:28 AM, Karen Tracey wrote: > That generally means the permissions don't allow the code to access the > file.  You don't mention if this happens with the dev server (which would > surprise me, since you can load the template from the shell) or only

Re: Serialize references to foreign keys

2009-03-29 Thread Russell Keith-Magee
On Sun, Mar 29, 2009 at 9:49 PM, Kariem wrote: > > I tried using the serialization as documented in > http://docs.djangoproject.com/en/dev/topics/serialization/ and do > something along the lines of > >        json = serializers.get_serializer('json')() >        

Re: TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Karen Tracey
On Sun, Mar 29, 2009 at 11:18 AM, Rob Hudson wrote: > > This is a stumper... > > I have a very simple view that is a wrapper around the generic view > direct_to_template. The loader finds the template as indicated in the > output "(File exists)", but yet I still get a

TemplateDoesNotExist error when postmortem says it exists?

2009-03-29 Thread Rob Hudson
This is a stumper... I have a very simple view that is a wrapper around the generic view direct_to_template. The loader finds the template as indicated in the output "(File exists)", but yet I still get a TemplateDoesNotExist error. Any ideas? I can go to the Django shell and load it just

Re: Problem with Field errors

2009-03-29 Thread Jack Orenstein
On Mar 29, 2009, at 9:35 AM, Matthew Somerville wrote: > > Jack Orenstein wrote: >> On Mar 28, 2009, at 12:26 PM, Daniel Roseman wrote: >> >>> On Mar 28, 4:14 pm, Jack Orenstein wrote: My application needs to validate data from a from beyond the validation of Fields

Re: Curious Error

2009-03-29 Thread Martin Ostrovsky
You're passing your template variable `classcolors` to the template filter `random`. Looking at the code for random.py: File "/usr/lib/python2.5/random.py", line 248, in choice return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty IndexError: string index out of

Re: Testing form posting

2009-03-29 Thread Martin Ostrovsky
You're POSTing the form instance, rather than the postedData. So: response = self.client.post('/myApp/post', form) should be: response = self.client.post('/myApp/post/', postedData) More info here: http://docs.djangoproject.com/en/dev/topics/testing/#making-requests On Mar 28, 9:14 pm,

Serialize references to foreign keys

2009-03-29 Thread Kariem
I tried using the serialization as documented in http://docs.djangoproject.com/en/dev/topics/serialization/ and do something along the lines of json = serializers.get_serializer('json')() json.serialize(o, ensure_ascii=False, fields=fields) "o" is a list of models that contain a

Re: Problem with Field errors

2009-03-29 Thread Matthew Somerville
Jack Orenstein wrote: > On Mar 28, 2009, at 12:26 PM, Daniel Roseman wrote: > >> On Mar 28, 4:14 pm, Jack Orenstein wrote: >>> My application needs to validate data from a from beyond the >>> validation of Fields done by django. So in my form handler, I check >>>

Re: django.contrib.auth.models.User User model can't be saved

2009-03-29 Thread Matthew Somerville
Joshua Partogi wrote: > Yes you're right. In my template I only have username, first_name, > last_name, email and password. I also print out the errors too. Nowhere are you printing out non-field specific errors - please read about non_field_errors at

Re: File upload: how to validate file type

2009-03-29 Thread Torsten Bronger
Hallöchen! P M writes: > yes you can, because signature of pdf is in the starting of 1st > chunk of stream... rest of the things are of hardly interest for > libmagic identification... Again, this is not the point. The point is whether I can safely read the first bytes and put them back into

Re: I love both Django and the Google Web Toolkit. Who else thinks tighter integration would be nice?

2009-03-29 Thread lkcl
sorry about re-beginning this thread but googlegroups decided to "close" responses. i accidentally replied privately to adam as a result, and will endeavour to reproduce what i wrote. as mentioned previously here on django-users, here is the beginnings of achieving exactly what adam is

Re: IndexError (list index out of range) in admin when updating a regex char primary key

2009-03-29 Thread TeenSpirit83
Karen you're always a big help for me on django. Thank you so much! I was imaging the same thing you explained about problems with the objects pointing to the key i want to change. So I was thinking to create a new counter primary key for that model and turn the current primary key into a simple

Re: Populating list_display with data from two models?

2009-03-29 Thread caliman
On 27 Feb, 01:56, Jamie Richard Wilson wrote: > I've extended the User model with a UserPofile model and have inline > editing working. Setup is something like this: > > class UserProfile(models.Model): >     user = models.ForeignKey( >        User, >        unique=True, >    

Re: Django Admin Question

2009-03-29 Thread Wiiboy
Ok, just determined that all I'll be doing is changing existing entries. So this is solved. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to