Le 29 déc. 07 à 05:25, Todd O'Bryan a écrit :

>
> After wrestling with newforms to get it to do things I thought it was
> never intended to do, I decided that either it was really intended to
> do such things or it's just such a clean design that getting it to do
> weird things isn't that hard.
>
> That said, I spent a lot of time fiddling around to find the right
> incantations, so I added a section to the Cookbook[1] called
> newforms[2] and included instructions for creating form fields
> dynamically[3] and altering the default order[4]. If anyone sees any
> obvious stupidness or this duplicates information available elsewhere,
> please let me know.
>
> Todd
>

Todd,

Thanks for those useful tricks. Here are some typo corrections, hope  
it helps:

> [4]: http://code.djangoproject.com/wiki/CookBookNewFormsDynamicFields

[4]: http://code.djangoproject.com/wiki/CookBookNewFormsFieldOrdering

In DynamicFields, you forgot to add 'self' as first argument of  
__init__.
In the same function you use range(len(iterable)) which is not really  
pythonic, I prefer this solution:

for i, question in enumerate(questions):
     self.fields['question_%d' % i] =  
forms.ChoiceField(label=questions, ...)

I know that it's a wiki and I can fix that myself but I prefer that  
you validate this choice, maybe I miss something?

Regards,
David
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to