python - Django Hidden Redirection -
I want to create a mechanism for in-app redirecting which will not redirect, but simply load another view function Please. So we say that I am going to will now go to my browser Now I want to do only on the server side, so when I go to I have called this type of redirection . Now I have a problem - when I go to that position - how does the reaction actually arise with the url? I can easily get the visual function by using How can I make any ideas how well it is ugly without You need to add the original request again at the bottom of the DNS request processing code. Requests are started from Then the solution will be something like this (untested!): Django.core.handlers.base import from BaseHandler class SmartRedirectMiddleware (object): def process_response (auto, request, Response): If iStance (Response, HTTPSMRRRERCRPS): Handler = Besandler () request.url = response.redirect_url resp = Handler .get_response (request) Return resp For real use, you Want some protection against loops and unlimited recycling. Or you can solve the problem differently - facilitate the browser to be restored based on the redirect. If it should be invisible, then it is easy to get acquainted with some client-side javascript. localhost: 8000 / a , the digenano looks at the last line of the scene and says
Returns HTTPRPSPoint Redirect ('/ B ')
localhost: 8000 / b>, see Django and return it to me.
localhost: 8000 / a and redirecting Django to
/ b , Then it gives the view for
/ b returns to all intermediate etc. (such as redirection will work) and without any redirection without any redirection (as for the user Has been observed).
HttpResponseSmartRedirect and just like this: (which runs in the form of all middlemen), want to create midware for that time, that Is: Example of
process_response check if response class
HttpResponseSmartRedirect on
resolution () to
urlsolvers , but I do not know that it should go through all the middle classes and have the same reaction How to make it compulsory I will get with accidental redirection. The closest way to do this is to call
urllib2.get (url) , but seeing that line, I have to destroy my computer.
urllib s?
BaseHandler.get_response to
django.core.handlers. Base .
Comments
Post a Comment