I've created my own class LocalSignup which extends the base django-allauth SignupView class with my own form and my own validation logic. The problem is that on success I cannot get the view to redirect to anything but the django LOGIN_REDIRECT_URL
in my settings.py. I have included a success_url
field in my class based view; I have tried overriding the get_success_url
function (see below); I have also tried passing my on success redirect using LocalSignup.as_view(success_url="/add_account_select/")
. None have worked. Any ideas on what I'm doing wrong?
class LocalSignup(SignupView):
form_class = AllAuthUserForm
template_name = 'signup/social_login.html'
success_url = '/add_account_select/' #reverse_lazy('add_account_select')
def get_success_url(self):
return '/add_account_select/' #reverse('add_account_select')
def dispatch(self, request, *args, **kwargs):
# self.sociallogin = request.session.get('socialaccount_sociallogin')
return super(LocalSignup, self).dispatch(request, *args, **kwargs)
def form_valid(self, form):
ret = super(LocalSignup, self).form_valid(form)
### MY FORM VALIDATION LOGIC
return ret
def get_context_data(self, **kwargs):
ret = super(LocalSignup, self).get_context_data(**kwargs)
ret.update(dict(username=self.sociallogin.account.user.first_name,
photo_url=self.sociallogin.account.get_avatar_url() ))
return ret
import pdb; pdb.set_trace()
) in your method to see if it gets invoked. If it is invoked you can step through the code to see where things go wrong. I am interested in hearing the outcome... – pennersr Mar 18 '13 at 11:50LocalSignup.dispatch
function is also called (afterCloseableSignupMixin.dispatch
and afterRedirectAuthenticatedUserMixin.dispatch
and afterSignupView.dispatch
). So the code is definitely called, but regardless it still returns theLOGIN_REDIRECT_URL
HttpRedirectRepose, which I can't quite figure out. Thanks again. – Hart Lambur Mar 19 '13 at 19:10form_valid
is where the success URL is used: github.com/pennersr/django-allauth/blob/… As you can see the success URL is retrieved (which should invoke your method), and then passed tocomplete_signup
, which in turn invokesperform_login
(github.com/pennersr/django-allauth/blob/…). Your URL should be passed all the time end should end up being used as the redirect URL. Add prints or step through to confirm this. – pennersr Mar 20 '13 at 20:13