Populate Custom User Attributes When Signing Up Using Django Allauth
Learn how to set custom attributes to your User model when signing up users with Django Allauth.
Django Allauth provides a plug-and-play authentication system with minimal configuration required.
However, you'll often require users to supply specific information while signing up.
In this post, I'll show you how to customize the allauth signup form and flow to store a field containing the user's company name.
Creating a Custom User Model
First, you'll add the field to your custom user model.
After that, you'll tell Django to use this model instead of the default one.
Customizing the Signup Process
You'll create a new sign up form inheriting from the one that allauth provides.
Then, you'll create an adapter to use the new field you added to the form.
Now, you'll tell allauth to use the new form on the signup page.
You'll also tell it to use your new adapter.
Try signing up now and you'll see the form asking for a company name. After signup up, you'll see the new user object contains the company name you entered during the process.
Summary
As you can see, allauth isn't only easy to integrate but also easy to customize.
To customize signup, all you need to do is to create a custom signup form, adapter, and then configure allauth to use them in settings.py