As an example, let's take a look at the 'next' parameter in django.contrib.auth
If the client is trying to access some resources which is only available for authenticated users, the login url will be modified and attached with extra parameter as ?next=the_next_url
. Then, the LoginForm
could set this parameter into context_data
and generate a form with a hidden input which contains its value like
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
However, how can I do this if I generate the form completely with django-crispy-form? In this case, the template file contains nothing but
{% crispy_tag form %}
form
will be set as context data, which means I have to push the parameter from request.GET in the form as a hidden input widget.
How could I do this?