I´m also interested in this question/answer - since the documentation
about forms lack more complex examples, form/formset-definitions are a
guessing game at times. not a huge problem though, because with some
experience and lots of research it´s (more or less) working.

but what´s "best practice" here? any benefits/drawbacks with either of
the solutions?

thanks,
patrick


On 27 Jun., 07:14, Anthony <[email protected]> wrote:
> I'm initializing my forms this way:
>
>     def __init__(self, league, *args, **kwargs):
>         super(TeamForm, self).__init__(*args, **kwargs)
>         self.fields["team"].queryset=Team.objects.filter(
>             league=league
>         )
>     ...
>
> But then I read this comment by Malcolm saying that I should move it
> into **kwargs instead and do it this way to avoid conflict with a
> possible "data" parameter passed in by Django:
>
>         def __init__(self, *args, **kwargs):
>            team = kwargs.pop("team")
>            super(TeamForm, self).__init__(*args, **kwargs)
>            ...
>
> (http://groups.google.com/group/django-users/browse_thread/thread/
> 3560bd448b04fd6d/98c3f4a5cb1e68ad?lnk=gst&q=formset#98c3f4a5cb1e68ad)
>
> Does his comment apply only to formsets or to forms in general?  I'd
> do it the second way from now on, but I'd like to know if I should go
> back and refactor all my previous forms definitions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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