title: "UNIQUE constraint failed: users_user.username" error?
body: <p>I'm studying user registration with Django, but I don't know why I get this error: <strong>UNIQUE constraint failed: users_user.username</strong> after trying to fill in the form. I have deleted the database and every migration/cache. It's with a custom user model where I use email as identifier. </p>
  
  <p>Is there something wrong with the code below, or do you have any suggestions?</p>
  
  <p>views.py</p>
  
  <pre><code>class RegisterView(CreateView):
  
      template_name = 'users/registration.html'
      form_class = RegisterForm
      success_url = '/'
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class RegisterForm(UserCreationForm):
  
  class Meta(UserCreationForm.Meta):
      model = User
      fields = ('email', 'password1', 'password2',)
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class User(AbstractUser):
      email = models.EmailField(
          verbose_name='Epostadresse',
          max_length=255,
          unique=True,
      )
      is_active = models.BooleanField(default=True)
      is_admin = models.BooleanField(default=False)
      veri_mail = models.BooleanField(default=False)
  
      objects = UserManager()
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = []
  </code></pre>