title: django models.DoesNotExist: matching query does not exist
body: <p>I am using Django 1.11 and typed below codes in models.py. It works fine when makemigrations, but it notices the error of "models.DoesNotExist" when do migrate.</p>
  
  <p>The code in models.py:</p>
  
  <pre><code>class RecordType(models.Model):
      name = models.CharField(max_length=100, default='out',blank=True, verbose_name="name")
  
  
  def get_record_type_default():
      return RecordType.objects.get_or_create(pk=1)[0].id
  
  
  class PrimaryCategory(models.Model):
      type = models.ForeignKey(RecordType, on_delete=models.PROTECT, default=get_record_type_default, verbose_name="type")
  
  
  def get_primary_category_default():
      return PrimaryCategory.objects.get_or_create(pk=1)[0].id
  
  
  class SecondaryCategory(models.Model):
      primary_category = models.ForeignKey(PrimaryCategory, on_delete=models.PROTECT, default=get_primary_category_default, verbose_name="1st category")
  
  
  def get_secondary_category_default():
      return SecondaryCategory.objects.get_or_create(pk=1)[0].id
  
  
  class Record(models.Model):
      secondary_category = models.ForeignKey(SecondaryCategory, on_delete=models.PROTECT, default=get_secondary_category_default, verbose_name="2nd category")
  </code></pre>
  
  <p>And here is the error message while doing migrate:</p>
  
  <pre><code>File "C:\Users\myname\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 464, in get_or_create
    return self.get(**lookup), False
  File "C:\Users\myname\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 380, in get
    self.model._meta.object_name
  datacore.models.DoesNotExist: SecondaryCategory matching query does not exist.
  </code></pre>