title: Excluding primary key in Django dumpdata with natural keys
body: <p>How do you exclude the primary key from the JSON produced by Django's dumpdata when natural keys are enabled?</p>
  
  <p>I've constructed a record that I'd like to "export" so others can use it as a template, by loading it into a separate databases with the same schema without conflicting with other records in the same model.</p>
  
  <p>As I understand Django's support for natural keys, this seems like what NKs were designed to do. My record has a unique <code>name</code> field, which is also used as the natural key.</p>
  
  <p>So when I run:</p>
  
  <pre><code>from django.core import serializers
  from myapp.models import MyModel
  obj = MyModel.objects.get(id=123)
  serializers.serialize('json', [obj], indent=4, use_natural_keys=True)
  </code></pre>
  
  <p>I would expect an output something like:</p>
  
  <pre><code>[
      {
          "model": "myapp.mymodel", 
          "fields": {
              "name": "foo", 
              "create_date": "2011-09-22 12:00:00", 
              "create_user": [
                  "someusername"
              ]
          }
      }
  ]
  </code></pre>
  
  <p>which I could then load into another database, using loaddata, expecting it to be dynamically assigned a new primary key. Note, that my "create_user" field is a FK to Django's auth.User model, which supports natural keys, and it output as its natural key instead of the integer primary key.</p>
  
  <p>However, what's generated is actually:</p>
  
  <pre><code>[
      {
          "pk": 123,
          "model": "myapp.mymodel", 
          "fields": {
              "name": "foo", 
              "create_date": "2011-09-22 12:00:00", 
              "create_user": [
                  "someusername"
              ]
          }
      }
  ]
  </code></pre>
  
  <p>which will clearly conflict with and overwrite any existing record with primary key 123.</p>
  
  <p>What's the best way to fix this? I don't want to retroactively change all the auto-generated primary key integer fields to whatever the equivalent natural keys are, since that would cause a performance hit as well as be labor intensive.</p>
  
  <p>Edit: This seems to be <a href="http://markmail.org/message/og5ch7ol3l5tg3mm" rel="noreferrer">a bug</a> that was <a href="https://code.djangoproject.com/ticket/13252" rel="noreferrer">reported</a>...2 years ago...and has largely been ignored...</p>