title: How to load a data fixture with get_by_natural_key() on ContentType foreign key in Django?
body: <p>I'm having trouble loading an external data fixture for a model that uses a <code>ContentType</code> foreign key. </p>
  
  <p>I'm using a manager in the models, like the docs say. Unfortunately, although the docs talk about the importance of a <code>get_by_natural_key</code> method on a <code>ContentType</code> foreign key, it then launches into a different example instead. I'm having trouble figuring out just what the manager would look like. My best guess is to use <code>get_by_natural_key</code> again, and assign <code>app_label</code> and <code>model</code> lookups, but I could be way off. </p>
  
  <pre><code># models.py 
  from django.db import models 
  from django.contrib.contenttypes.models import ContentType 
  from django.utils.translation import ugettext_lazy as _ 
  
  class InlineTypeManager(models.Manager): 
      def get_by_natural_key(self, title, app_label, model): 
          return self.get(title=title, content_type=ContentType.objects.get_by_natural_key(app_label=content_type__name, model=content_type__id)) 
  
  class InlineType(models.Model): 
      title = models.CharField(_("title"), max_length=255) 
      content_type = models.ForeignKey(ContentType, limit_choices_to={"model__in": ("Link", "Document", "Image", "Audio", "Video", "MediaSet", "Flash", "Testimonial")}) 
  
      objects = InlineTypeManager() 
  
      class Meta: 
          ordering  = ["title"] 
          verbose_name = _("inline type") 
          verbose_name_plural = _("inline types") 
  
      def __unicode__(self): 
          return u"%s" % (self.title) 
  </code></pre>
  
  <p><a href="https://docs.djangoproject.com/en/dev/topics/serialization/#natural-keys" rel="nofollow">https://docs.djangoproject.com/en/dev/topics/serialization/#natural-keys</a> </p>
  
  <p>My <code>initial_data.json</code>:</p>
  
  <pre><code>[
      {
          "model": "inlines.inlinetype",
          "pk": 1,
          "fields": {
              "title": "Image",
              "content_type": "image"
          }
      }, {
          "model": "inlines.inlinetype",
          "pk": 2,
          "fields": {
              "title": "Video",
              "content_type": "video"
          }
      }
  ]
  </code></pre>
  
  <p>When I <code>loaddata</code> my JSON, I receive the error: </p>
  
  <pre><code>DeserializationError: [u"'image' value must be an integer."] 
  </code></pre>
  
  <p>The point of <code>get_by_natural_key</code> is to load non-integer fields in a "human-friendly" lookup because hard-coded IDs in the JSON is a bad idea because of its unpredictability, so I'm guessing my manager is failing. Or should I use <code>get_for_model()</code>/<code>get_for_models()</code>?</p>