Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you want to render the form, the browser makes a GET request to your Django app (this has nothing to do with <code>request.GET</code> and <code>request.POST</code>, which merely contain data sent as URL parameters or form-encoded data respectively, and are always available). Since you are using the <code>next</code> URL parameter during the GET request, you will have access to it then. However, you then proceed to render the form page as a response to the request without including <code>next</code> anywhere, so browser no longer has access to this value, nor does your app.</p> <p>When the browser then proceeds to submit the form, it does so by performing a POST request. It so happens that you are using the same handler to handle this request, but it is still a separate request, and therefore, <code>next</code>, which you are not passing through the form or URL parameter, is lost.</p> <p>You can fix this in the original GET request (before showing the form to the user). As soon as you receive the <code>next</code> URL parameter, you can do one of the following:</p> <p><strong>Put it in the login form</strong> by passing the value to the template via context, and rendering a hidden field within the form:</p> <pre><code>&lt;!-- inside your FORM element --&gt; &lt;input type="hidden" name="next" value="{{ next }}"&gt; </code></pre> <p><strong>Putting next in session</strong> during GET request:</p> <pre><code>request.session['next'] = request.GET.get('next', '/') </code></pre> <p>There are more methods (e.g., adding hidden field in the login form class), but the above two are most straightforward.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload