I'm trying to create a multi form signup with django allauth. (I originally tried django wizard, but opted out of that as sign up isn't necessarily a linear path, depending on earlier form data filled out by the user). What's the best way to get django allauth to work with multi page signup?
I thought that using a series of form views with the first creating the user and login them in:
@require_http_methods(['GET', 'HEAD', 'POST'])
def profile_view(request, price_id):
form = ProfileForm()
if request.method == 'POST':
form = ProfileForm(request.POST)
if form.is_valid():
form.save()
user = authenticate(request, username=form.cleaned_data['email'],
password=form.cleaned_data['password1'])
login(request, user)
return redirect('users:supply_address')
return render(request, 'pages/signup.html', {'form': form})
followed by a series of similar views which require login and then ending with a view that uses the complete_signup
method from django-allauth.
@login_required
@require_http_methods(['GET', 'HEAD', 'POST'])
def direct_debit_view(request):
form = DirectDebitForm()
if request.method == 'POST':
form = DirectDebitForm(data=request.POST)
if form.is_valid():
request.session.update(form.cleaned_data)
complete_signup(request, user, settings.ACCOUNT_EMAIL_VERIFICATION,settings.LOGIN_REDIRECT_URL)
return redirect(settings.LOGIN_REDIRECT_URL)
return render(request, 'pages/signup_postcode.html', {'form': form})
And overridding the url used for login for django-allauth to point to the first signup view. However I'm not sure if this is the best approach?
url(r'^account/signup/$', views.profile_view, name='profile'),