1π
I think this really depends on your problem and what exactly you are trying to do.
You cannot change the URL without redirecting the user, as you cannot modify the URL on a page without a reload. Basically a redirect is a response telling the user to move on, there is no way to actually change the URL. Note that even if you do it in something like JavaScript you basically do the same as a redirect, so it canβt be done client or server side.
I think it might help if you explain to us why you need to pass this information via the URL. Why not store data in the session?
I guess you could add the data to the request object but that doesnβt add it to the URL.
4π
class YourRedirectMiddleware:
def process_request(self, request):
redirect_url = request.path+'?par1=1&par2=2'
return HttpResponsePermanentRedirect(redirect_url)
what are you trying to accomplish and why this way?
- [Django]-How to get checkbox values in django application
- [Django]-Django creates another media folder inside media folder
0π
You can do whatever you like in the middleware. You have access to the request object, you can get the URL and redirect to a new one if you want.
My question would be, why do you want to do this? If you need to keep information about the request, the proper place to do this is in the session.