Form.save returns object. You don't need tricking with post directly.
11 груд. 2015 22:30 "Dino" <firstlett...@googlemail.com> пише:

> The form submission and processing as I've done it works,
> but I'm not sure its the right way.
>
> The part I'm concerned about is detailed in these 3 steps:
> - I save the form with the data submitted -- form.save()
> - then I check request.POST for the name of a (unique) field submitted
> - then I query the database for the object with the field specified in
> request.POST,  to process it further.
>
> Can't I access the object easier ?  ( either before or after saving the
> form)
>
> class FormViewCustom(FormView):
>     form_class = SomeForm
>     success_url = reverse_lazy("index")
>     template_name = "index.html"
>
>     def form_valid(self, form):
>         form.save(commit=True)
>         .......................................
>         request_field = self.request.POST['fieldx']
>         retrieve_model = MyModel.objects.filter(fieldx =
> request_field).get()
>
>         #and now process the object before returning
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6913290d-2be5-467e-a307-b03a111c9b2d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6913290d-2be5-467e-a307-b03a111c9b2d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADTRxJO%3Dphd1mmn_hy9fdgD9a9NreX1THdYNx5AnuFRrxcgN6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to