I do not know if this is possible, but I would like to add a few parameters at the end of the URL using middleware. Can this be done without redirecting after requesting a fix to the url?
i.e. user clicks: ... / some_link and middleware overwrites it: ... / some_link? par1 = 1 & par2 = 2
Another way is to change the response and replace each HTML link, but that is not what I would like to do.
thanks
I think it really depends on your problem and what exactly you are trying to do.
URL- , URL- . - , , URL. , JavaScript, , , .
, , , URL-. ?
, , URL.
class YourRedirectMiddleware: def process_request(self, request): redirect_url = request.path+'?par1=1&par2=2' return HttpResponsePermanentRedirect(redirect_url)
?
You can do whatever you want with middleware. You have access to the request object, you can get the URL and redirect to a new one if you want.
My question will be, why do you want to do this? If you need to save request information, a suitable place for this would be in the session.
Source: https://habr.com/ru/post/1718259/More articles:Should stored procedures be a lot or focused? - stored-proceduresg ++ problem: there was no exception - c ++Hows makes window color calculated from ARGB - c #Python ctypes and not enough arguments (4 bytes missing) - pythonHow to override control panel more controller? - iphoneRendering a large number of cells (objects) - graphicsPython. Есть ли способ "os.listdir()" возвращать тарабарщину для плохого имени папки? - python doesn’t work on XSD? - xmlУстановка определенных бит в число - javascriptWhen the time has come to say: "Now I need to create a user control!" - .netAll Articles