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.

--
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to