I m not familiar with django and I have found several problems trying
to sent a httpresponse with post parameters. I would like to return an
httpresponse (or httpredirect) to a new url with the request
parameters via post.
Could anybody help me?
Thank you in advance,
Miguel
I have defined a new view:
def prueba(request, seccion):
if request.POST:
new_data = request.POST.copy()
> I m not familiar with django and I have found several problems trying > to sent a httpresponse with post parameters. I would like to return an > httpresponse (or httpredirect) to a new url with the request > parameters via post.
> Could anybody help me? > Thank you in advance, > Miguel
After a post you should use a HttpResponseRedirect(url). If you need to have access to the post parameters an option is to save them in a session, or encode them in the url itslef.
The problem is that I need to redirect the request to an url and post to
this url the parameters I got from the initial request and display the post
url. Here is my views.py:
> > I m not familiar with django and I have found several problems trying
> > to sent a httpresponse with post parameters. I would like to return an
> > httpresponse (or httpredirect) to a new url with the request
> > parameters via post.
> > Could anybody help me?
> > Thank you in advance,
> > Miguel
> After a post you should use a HttpResponseRedirect(url). If you need
> to have access to the post parameters an option is to save them in a
> session, or encode them in the url itslef.
but that won't force the client browser to use a POST when retrieving the redirect location. The redirect response contains a status code and location, there is no field for the server to specify what method should be used to access the specified location. Standards actually specify that the browser must use the same method as was used on the original request (which seems to be what you want), but that is not, in fact, what most browsers do. See:
thanks karen, that is what I meant.
So there is no way to return in my views.py an external web html with post
parameters ... it must be a way to do that, dont think so?
> but that won't force the client browser to use a POST when retrieving the
> redirect location. The redirect response contains a status code and
> location, there is no field for the server to specify what method should be
> used to access the specified location. Standards actually specify that the
> browser must use the same method as was used on the original request (which
> seems to be what you want), but that is not, in fact, what most browsers
> do. See:
> thanks karen, that is what I meant. > So there is no way to return in my views.py an external web html with post > parameters ... it must be a way to do that, dont think so?
well, I am not a python programmer and maybe I am doing silly things or this
is not as complex as I see but I not able to do what you mention above.
I get the error,
'NoneType' object has no attribute 'read'
I have tried to follow http://code.activestate.com/recipes/146306/, with
only fields (the fields of my form) but I get stack here return
h.file.read() with the mentioned error.
I have also tried httplib.HTTPS but there is no way to get the results I
wanted.
(i have also commeted errcode, errmsg, header = ..., because i got some
errors)
here is my code:
But here I get the URL of my django place in my browser instead of
https://sis.sermepa.es/sis/realizarPago. I mean, all the images and
resources are refered to relative paths and I not able to display the page.
For sure return HttpResponse(content) is not the way as Antoni commented.
On Tue, Feb 17, 2009 at 7:28 PM, Antoni Aloy <antoni.a...@gmail.com> wrote:
> 2009/2/17 Miguel <migue...@gmail.com>:
> > thanks karen, that is what I meant.
> > So there is no way to return in my views.py an external web html with
> post
> > parameters ... it must be a way to do that, dont think so?
I have no problem pulling pages using httplib if the pages do not
require authentication. But now I want to pull pages only after
authenticating. Access is enforced by the contributed auth package.
As I said, when hitting pages that do not require auth, I am
successful and get a 200 response code. But when auth is needed, I
get 302 for the code and "found" for the status.
Any insights?
On Feb 17, 12:28 pm, Antoni Aloy <antoni.a...@gmail.com> wrote:
On Fri, 2009-02-20 at 19:39 -0800, Devin wrote: > I have no problem pulling pages using httplib if the pages do not > require authentication. But now I want to pull pages only after > authenticating. Access is enforced by the contributed auth package.
> As I said, when hitting pages that do not require auth, I am > successful and get a 200 response code. But when auth is needed, I > get 302 for the code and "found" for the status.
> Any insights?
So you need to act like a browser would. Submit the necessary authentication form variables, save the returned cookie and send it on subsequent requests.
Not sure how this is related ot the original question in the thread, though, which was about redirecting what the user's browser retrieves, not retrieving web pages inside Python scripts.