title: Django: ValueError: Cannot create form field because its related model has not been loaded yet
body: <p>I'm having some trouble with a Django project I'm working on. I now have two applications, which require a fair bit of overlap. I've really only started the second project (called <code>workflow</code>) and I'm trying to make my first form for that application. My first application is called <code>po</code>. In the <code>workflow</code> application I have a class called <code>WorkflowObject</code>, which (for now) has only a single attribute--a foreign key to a <code>PurchaseOrder</code>, which is defined in <code>po/models.py</code>. I have imported that class with <code>from po.models import PurchaseOrder</code>. </p>
  
  <p>What I'm trying to do is have a page where a user creates a new <code>PurchaseOrder</code>. This works fine (it's the same form that I used in my <code>PurchaseOrder</code> application), and then uses that instance of the class to create a <code>WorkflowObject</code>. The problem now, is that I get the error: <code>ValueError: Cannot create form field for 'purchase' yet, because its related model 'PurchaseOrder' has not been loaded yet</code>. I'm really not sure where to start with this. It was working ok (allowing me to create a new <code>PurchaseOrder</code> and forward to a url with its primary key in the url) until I added the view that should allow me to create a new <code>WorkflowObject</code>. I'll put that specific view here: </p>
  
  <pre><code>from django.http import HttpResponse, HttpResponseRedirect
  from django.shortcuts import render, get_object_or_404
  from django_tables2 import RequestConfig
  from po.models import PurchaseOrderForm, PurchaseOrder
  from workflow.models import POObject, WorkflowForm
  
  
  def new2(request, number):
   po=PurcchaseOrder.objects.get(pk=number)
   if request.method == 'POST':
     form = WorkflowForm(request.POST)
     if form.is_valid():
        new_flow = form.save()
        return HttpResponse('Good')
     else:
        return render(request, 'new-workflow.html', {'form': form, 'purchase': po})
    else:
      form = WorkflowForm()
      return render(request, 'new-workflow.html', {'form': form, 'purchase': po})
  </code></pre>
  
  <p>The lines of code that seem to be causing the error (or at least, one of the lines that is shown in the traceback) is: </p>
  
  <pre><code>class WorkflowForm(ModelForm):
     purchase = forms.ModelChoiceField(queryset = PurchaseOrder.objects.all())
  </code></pre>
  
  <p>EDIT: 
  I seem to have made a very noob mistake, and included parentheses in my definition of <code>WorkflowObject</code>, that is, I had said <code>purchase=models.ForeignKey('PurchaseOrder')</code>, instead of <code>purchase=models.ForeignKey(PurchaseOrder)</code></p>