[Answer]-Django view that rewrites URL to contain username as a query parameter?

1👍

Why would you want to add a get parameter to each view while the request already contains the user? Also you should probably use the middleware layer to log user actions.

0👍

I don’t think you would have to change anything except the templates for this.

If your existing url like http://server/myapp/view1 then accessing an url like this http://server/myapp/view1?username=foo will also work.

So your existing views will work as is.

However, you will have to change templates that renders the links as per new scheme. For example for above view if you are doing {% url 'view1' %} to get a link, then you will have to change it to {% url 'view1'%}?username={{user}}.

👤Rohan

Leave a comment