title: How to populate inherited MPTT fields while creating a Django fixture?
body: <p>I'm following the instructions <a href="https://docs.djangoproject.com/en/dev/howto/initial-data/" rel="nofollow">here</a> to create my first Django fixture. I've created a JSON file. But there is a complication: The model I'm trying to populate inherits from <code>MPTTModel</code></p>
  
  <p>Here is what my Django JSON fixture file <code>initial_data.json</code> looks like:</p>
  
  <pre><code>[
      {
           "model": "MyApp.MyModel", 
           "pk": 1, 
           "fields": {
               "level": 0, 
               "parent": null, 
               "name": "My String"
           }
      }
  ]
  </code></pre>
  
  <p>When I run this fixture, I get the error shown below. It turns out there are a handful of other fields that must be defined in the fixture for this model: <code>rght</code>, <code>lft</code>, <code>tree_id</code>, <code>level</code>.</p>
  
  <pre><code>django.db.utils.IntegrityError: Problem installing fixture    
  'MyApp/fixtures/initial_data.json': Could not load MyApp.MyModel(pk=1): 
      null value in column "lft" violates not-null constraint
  Failing row contains (1, My String, null, , null, null, null, 0).
  </code></pre>
  
  <p>I can figure out what the <code>level</code> attribute is supposed to be and insert it into the fixture file. But how am I supposed to figure out and set the values of <code>rght</code>, <code>lft</code>, <code>tree_id</code> in the this fixture?</p>