[Django]-How to post to allauth signup form to fill in initial data?

3👍

I found a solution to this problem. Instead of posting the first form to the second one, I posted to an intermediary view, saved the email address in the session, then redirected to the allauth signup form. I extended the allauth signup form to check the session for this initial email address.

The first form action is:
{% url ‘my_signup_email’ %}

In urls.py:

url(r'^accounts/signupemail/', 'projectname.views.signup_email',name='my_signup_email'),
url(r'^accounts/signup/?', 'projectname.views.signup', name='my_signup'),

In views.py:

def signup_email(request):
    request.session['email_initial'] = request.POST.get('email')
    return redirect('my_signup')

class MySignupView(SignupView):
    def get(self, request, *args, **kwargs):
        self.initial = {"email":request.session.get('email_initial')}
        return super(MySignupView, self).get(self, request, *args, **kwargs)
signup = MySignupView.as_view()

If anyone has any criticism of this solution, I would be interested to hear it.

Leave a comment