title: ValueError: Cannot create form field for 'author' yet, because its related model 'settings.AUTH_USER_MODEL' has not been loaded yet
body: <p>I am trying to set up a basic blog with a custom auth model. I am trying to get a simple form to work but somehow I am not able to make it work. I am not sure what is causing the error. This is a fresh app and a fresh project I am working on. </p>
  
  <p>I tried to reference from the docs but I am not sure what I am doing incorrect. How can i fix this error? Thanks in advance</p>
  
  <p>Docs: <a href="https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project" rel="nofollow noreferrer">https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#changing-to-a-custom-user-model-mid-project</a></p>
  
  <p>Similar questions: <a href="https://stackoverflow.com/questions/18083099/cannot-create-form-field-for-created-by-yet-because-its-related-model-users">Cannot create form field for &#39;created_by&#39; yet, because its related model &#39;users.User&#39; has not been loaded yet</a></p>
  
  <p><strong>My Current Code</strong></p>
  
  <p>models.py</p>
  
  <pre><code>class User(AbstractUser):
    pass
  
  class Post(models.Model):
     author = models.ForeignKey('settings.AUTH_USER_MODEL')
     title = models.CharField(max_length=200)
     text = models.TextField()
     created_date = models.DateTimeField(default=timezone.now)
     published_date = models.DateTimeField(blank=True, null=True)
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>from blog.models import User
  
  class PostForm(forms.ModelForm):
  image = forms.CharField(
      widget=forms.FileInput(attrs={'class': 'form-control'}),required=False)
  
  
  class Meta():
      model = Post
      fields = ('author','title', 'text','image')
      widgets = {
          'title': forms.TextInput(attrs={'class': 'textinputclass'}),
           }
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from blog.forms import PostForm, CommentForm
  
  class CreatePostView(LoginRequiredMixin,CreateView):
    ...
    form_class = PostForm
    model = Post
    def form_valid(self,form):
      if self.request.POST:
          post = form.save()
          return HttpResponseRedirect('/')
  </code></pre>
  
  <p>settings.py:</p>
  
  <pre><code>AUTH_USER_MODEL = 'blog.User'
  </code></pre>
  
  <p>admin.py:</p>
  
  <pre><code>from .models import User
  from django.contrib.auth.admin import UserAdmin
  admin.site.register(User,UserAdmin)
  </code></pre>