title: Manager isn't available; 'auth.User' has been swapped for 'polls.User'
body: <p>I have created a different version of the User model where there is no username field and I am now trying to implement a sign in feature, but I keep getting the error </p>
  
  <pre><code>Manager isn't available; 'auth.User' has been swapped for 'polls.User'
  </code></pre>
  
  <p>I have searched the rest of this site and tried to implement the feature beneath to fix the problem but to no avail.</p>
  
  <pre><code>from django.contrib.auth import get_user_model
  
  User = get_user_model()
  </code></pre>
  
  <p>Here is the rest of my files</p>
  
  <p>Views</p>
  
  <pre><code>    from django.http import HttpResponse
      from django.shortcuts import get_object_or_404, render, render_to_response, redirect
      from django.contrib.auth.decorators import login_required
      from django.contrib.auth import login, authenticate
      from django.shortcuts import render, redirect
  
      from polls.forms import SignUpForm
      from django.contrib.auth import get_user_model
  
      User = get_user_model()
  
      @login_required
      def home(request):
          return render(request, 'home.html')
  
      def signup(request):
          if request.method == 'POST':
              form = SignUpForm(request.POST)
              if form.is_valid():
                  form.save()
                  username = None
                  raw_password = form.cleaned_data.get('password1')
                  user = authenticate(password=raw_password)
                  login(request, user)
                  return redirect('home')
          else:
              form = SignUpForm()
          return render(request, 'signup.html', {'form': form})
  </code></pre>
  
  <p>forms</p>
  
  <pre><code>from django import forms
  from django.contrib.auth.forms import UserCreationForm
  from django.contrib.auth.models import User
  
  
  class SignUpForm(UserCreationForm):
      first_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
      last_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
      email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
      username = None
  
      class Meta:
          model = User
          fields = ('first_name', 'last_name', 'email', 'password1', 'password2', )
  </code></pre>
  
  <p>models</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractUser, BaseUserManager
  from django.db import models
  from django.utils.translation import ugettext_lazy as _
  
  class UserManager(BaseUserManager):
      """Define a model manager for User model with no username field."""
  
      use_in_migrations = True
  
      def _create_user(self, email, password, **extra_fields):
          """Create and save a User with the given email and password."""
          if not email:
              raise ValueError('The given email must be set')
          email = self.normalize_email(email)
          user = self.model(email=email, **extra_fields)
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_user(self, email, password=None, **extra_fields):
          """Create and save a regular User with the given email and password."""
          extra_fields.setdefault('is_staff', False)
          extra_fields.setdefault('is_superuser', False)
          return self._create_user(email, password, **extra_fields)
  
      def create_superuser(self, email, password, **extra_fields):
          """Create and save a SuperUser with the given email and password."""
          extra_fields.setdefault('is_staff', True)
          extra_fields.setdefault('is_superuser', True)
  
          if extra_fields.get('is_staff') is not True:
              raise ValueError('Superuser must have is_staff=True.')
          if extra_fields.get('is_superuser') is not True:
              raise ValueError('Superuser must have is_superuser=True.')
  
          return self._create_user(email, password, **extra_fields)
  
  
  class User(AbstractUser):
      """User model."""
  
      username = None
      email = models.EmailField(_('email address'), unique=True)
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = []
  
      objects = UserManager()
  </code></pre>
  
  <p>If anyone could provide any clarity on this it would be greatly appreciated</p>