title: Avoid username field creation in custom user model for django allauth
body: <p>I'm using a custom user model with allauth and I need to have the username field omitted. I've already seen the docs and a whole bunch of stackoverflow answers about using <code>ACCOUNT_USER_MODEL_USERNAME_FIELD = None</code> but all of this still leads my database to have an username field.</p>
  
  <p>Now since the db still has an <code>username</code> field with the unique constraint set on <strong>and</strong> allauth will not put a username in the field with the aforementioned setting set to <code>None</code>, this causes me to face <code>IntegrityError</code> after the very first user creation. I know I can solve this by just having the aforementioned setting be set to <code>'username'</code> but I'm curious, how do I just not make the username, because I'm never using it.</p>
  
  <p>My model:</p>
  
  <pre class="lang-py prettyprint-override"><code>class CustomUser(AbstractUser):
      # Custom user model for django-allauth
      first_name = None
      last_name = None
  
      def delete(self):
          # Custom delete - make sure user storage is also purged
          # Purge the user storage
          purge_userstore(self.email)
          # Call the original delete method to take care of everything else
          super(CustomUser, self).delete()
  
  </code></pre>
  
  <p>It doesn't really do much except override the <code>delete</code> function. This override is irrelevant in this topic but I included it just for the sake of completeness. It also sets <code>first_name</code> and <code>last_name</code> to <code>None</code>, which works perfectly and removes those fields from the database as expected. I've tried setting <code>user</code> to <code>None</code> but that does nothing. I've also tried setting <code>username</code> to <code>None</code> but that will raise a <code>FieldNotFound</code> error with <code>ACCOUNT_USER_MODEL_USERNAME_FIELD = None</code></p>
  
  <p>My settings (the relevant bit):</p>
  
  <pre class="lang-py prettyprint-override"><code>AUTHENTICATION_BACKENDS = (
      "django.contrib.auth.backends.ModelBackend",
      "allauth.account.auth_backends.AuthenticationBackend",
  )
  AUTH_USER_MODEL = 'custom_account.CustomUser'
  ACCOUNT_USER_MODEL_USERNAME_FIELD = None
  ACCOUNT_USERNAME_REQUIRED = False
  ACCOUNT_EMAIL_REQUIRED = True
  ACCOUNT_UNIQUE_EMAIL = True
  ACCOUNT_AUTHENTICATION_METHOD = 'email'
  </code></pre>
  
  <p>My migration file:</p>
  
  <pre class="lang-py prettyprint-override"><code>migrations.CreateModel(
              name='CustomUser',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('password', models.CharField(max_length=128, verbose_name='password')),
                  ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
                  ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
                  ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
                  ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
                  ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
                  ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
                  ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
                  ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
                  ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
              ],
  ....
  </code></pre>
  
  <p>This migration generation confuses me to no end. Why is the <code>username</code> field still there? Why is it set to be the only unique constraint even though I've clearly set <code>ACCOUNT_UNIQUE_EMAIL = True</code>?</p>
  
  <p><strong>Note</strong>: This migration file is generated from a clean slate, this is the first and only migration file generated from the code I have presented.</p>
  
  <p>At first I thought, my settings were simply not being read. But I checked <code>django.conf.settings</code> and <code>allauth.account.app_settings</code> (in the shell) for these changes and they were all updated. What's going on here?</p>
  
  <p><strong>Note</strong>: Amongst the many stackoverflow questions I've searched, <a href="https://stackoverflow.com/questions/42160475/django-allauth-empty-username-causes-duplicate-key-in-postgress-db">this</a> question in particular seems to explain my issue perfectly. With one small problem, the answer by the creator of allauth himself suggested to use <code>ACCOUNT_USER_MODEL_USERNAME_FIELD = "username"</code> as the model in question was "clearly using the <code>username</code> field". But the answer does not explain what to do when you don't want to use the <code>username</code> field at all.</p>