On Thursday, February 7, 2013 3:39:43 AM UTC-5, Some Developer wrote: > > On 06/02/13 23:00, Rainy wrote: > > On Wednesday, February 6, 2013 3:09:39 PM UTC-5, Some Developer wrote: > > > > Why doesn't the form_valid() (and for that matter the > form_invalid()) > > method in the FormView generic class based view take a request > > argument? > > > > I've found that if you have a form which requires you to override > the > > form_valid() method because you need to do custom logic before you > save > > the model and you need to save the user ID of the person who posted > the > > form you need to also override the post() method in order to pass on > > the > > correct data by manually adding it to the post argument of the > > form_valid() method by using request.user. > > > > Am I missing something here? Is there any easier way to achieve what > I > > want to achieve? > > > > > > > > How about using self.request attribute? -rainy > > Heh I don't know how I missed that. Thanks, that solves a couple of > issues :). > > I'm in the process of converting some old code to class based views and > am still getting used to using them. > >
No problem. There's of course also self.args and self.kwargs. If you need to use views that inherit from multiple CBVs, take a look at my tutorial that uses modified GCBVs: http://lightbird.net/dbe2/ (I will add more tutorials in near future) HTH, -rainy -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.

