Skip to content Skip to sidebar Skip to footer

How I Can Match On The ?next=/nextpage/ Value When I Decorate A View With @login_required?

How i can match on the ?next=/nextpage/ value when i decorate a view in django with @login_required? It's not working on the 'standard way' (in url.py via regular expression matchi

Solution 1:

Django only matches paths based on the path of the URL, not the querystring.

This means that anything after '?' in your request from the server is not considered when deciding which view to serve up. Instead, that part of the string is turned into a dictionary like object.

so if you request:

/login/?next=/nextpage/

Django will use /login/ to find the view, and will populate request.GET with data {'next':'nextpage'}. Tell us what you're actually trying to do and I'll try to find a more Django-esque way for your to accomplish it.

Edit after additional information supplied:

The querystring ?next=/nextpage/ is probably not being sent when you submit the form with the POST method. Submitting the form will POST data to the URL specified in the form's action attribute.

Post a Comment for "How I Can Match On The ?next=/nextpage/ Value When I Decorate A View With @login_required?"