2010/1/7 Andreas Pfrengle <a.pfren...@gmail.com>:
> However I'm wondering how I would transform this concept on Formsets.
> I think I would somehow need to expand already the formsets __init__
> to accept the additional 'request' parameter (otherwise I get "__init__
> () got an unexpected keyword argument 'request'"), and then push it
> forward to the forms __init__.

When writing code like this, I try to use this sort of pattern, where
by the child class need not know any intricate details about it's
parent class's constructor, only which parameters are for the child
class. Looks like this:

class FooForm(forms.Form):
  def __init__(self, *args, **kwargs):
    self.request = kwargs.pop('request', None)
    super(forms.Form, self).__init___(*args, **kwargs)
    # do stuff with self.request


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.


Reply via email to