Tuesday, January 27, 2015

Re: read GET and POST simultaneously?

Absolutely no problem at all doing that.
The only thing that's confusing here is that `request.GET` is a misleading name.
The query parameters are available on any request, regardless of the HTTP method.

> Is this reliable behavior across browsers?

Yes.

> Is it a dumb idea for reasons I haven't thought of? 

No.

Cheers,

  Tom

On Tuesday, 27 January 2015 03:26:52 UTC, Eric Abrahamsen wrote:
As far as I can tell (testing with the Conkeror web browser), it's
possible to read both GET and POST at once: if a user POSTs to a URL
containing GET parameters, you can get them both in the view.

Is this reliable behavior across browsers? Is it a dumb idea for reasons
I haven't thought of?

A bit of background, in case there's simply a better approach to this:

I'm using GET parameters to create custom model formsets: depending on
those parameters, I construct different initial data, and set some of the
form fields to use hidden input -- this makes it much easier for users
to input bulk model instances without having to mess with endless
drop-down menus.

But I need the same initial data when handling the POST request, which
means I either need to re-read the GET parameters in the POST method
(I'm not sure that's reliable), or I need to otherwise store the values
of those parameters (ie in the session), and read them again from there
during POST.

URL arguments would be stable, but there are many different possible
parameters, half of which won't even be present for any given formset,
and I don't know how to handle that using URL segments.

I'd be interested in hearing any thoughts on this!

Thanks,
Eric

--
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+unsubscribe@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/e86ddccc-8068-4d73-bbff-cb6e2a3ec8b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment