read GET and POST simultaneously?

38 views
Skip to first unread message

Eric Abrahamsen

unread,
Jan 26, 2015, 10:26:52 PM1/26/15
to django...@googlegroups.com
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

Tom Christie

unread,
Jan 27, 2015, 4:55:39 AM1/27/15
to django...@googlegroups.com, gir...@gmail.com
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

Eric Abrahamsen

unread,
Jan 27, 2015, 10:09:29 AM1/27/15
to django...@googlegroups.com
Tom Christie <christ...@gmail.com> writes:

> 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.

Thank you very much!
Reply all
Reply to author
Forward
0 new messages