Suppose a user is on the page /some_url/
on a site with django-allauth. When clicking "Login" they get sent to a URL like:
/accounts/login/?next=/some_url/
If they are already a registered user, after logging in here, they get sent to the /some_url/
, which is fine.
But if they're not registered, and they click "sign up", they get sent to:
/accounts/signup/?next=/some_url/
Suppose I want to send the user to some onboarding experience, at /onboarding/
, straight after they sign up.
What's the simplest way to override allauth's default behaviour, and send the user to /onboarding/
even if a next=/some_url/
is specified?
The simplest way would be to override the template account/signup.html
with your own copy. If you examine that template you will see the following section:
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
If you remove the if
/endif
part and change the value inside, the signup page will redirect to a specific page, even if you pass a next
argument in the URL:
<input type="hidden" name="{{ redirect_field_name }}" value="/onboarding/" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With