I've read multiple threads on SO and have dig deep into allauth source code as well, but was not able to set dynamic redirection_url after logging/signing up.
So, my use-case is to redirect the user on the same page where he/she is presently at. I've a login form on every page(basically base.html), but it redirects everytime to the index page.
This is what I've tried.
1) Adding hidden input field with name as next as mentioned here
```
<form role="form" class="form-horizontal">
<fieldset>
<div class="form-group signup_fb_wrapper">
<input type="hidden" name="next" value="/add_account_select/" />
<a class="btn wordwrapper btn-facebook btn-block" href="/accounts/facebook/login/?next={{request.path}}">
<span class="fa fa-facebook"></span> Signup with Facebook
</a>
</div>
</fieldset>
</form>
Also, I've tried adding next as a query parameter in the href itself. but still no luck.
2) Over-ridding the Adapter class method get_login_redirect_url as mentioned here.
class MyAdapter(DefaultAccountAdapter):
def get_login_redirect_url(self, request):
return request.GET['next']
After logging in, I everytime get redirected to /. How can I changed the re-direction URL dynamically?
Hi @prafulbagai , any chance you could share how you managed to do that?
I don't know if this works but i think one way would be to override the template account/signup.html with your custom modifications. If you look at that template you will see this part:
{% if redirect_field_value %}
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
Then you need to change the value inside the input tag to this:
<input type="hidden" name="{{ redirect_field_name }}" value="{% url 'your-custom-url' %}" />
Most helpful comment
Hi @prafulbagai , any chance you could share how you managed to do that?