title: Django Model deserialization with empty PK
body: <p>I've serialized my django model:</p>
  
  <pre><code>serializers.serialize(MyModel.objects.filter(color="Red"))
  </code></pre>
  
  <p>and got this output:</p>
  
  <pre><code>&lt;object model="example.example" pk="133"&gt;
      &lt;field name="name" type="CharField"&gt;John Smith&lt;/field&gt;
      &lt;field name="color" type="CharField"&gt;Red&lt;/field&gt;
      ... #more fields
  &lt;/object&gt;
  </code></pre>
  
  <p>So you can see I have pk="133":</p>
  
  <p>And now I want to deserialize this into django model again and save() into database but with different pk so it should create new record with new id.</p>
  
  <p>I'm trying to parse XML and change pk using:</p>
  
  <ul>
  <li>pk="" - parser complains that pk should be integer</li>
  <li>pk="-1" or "0" - actually creates record with id/pk = "1" or "0"</li>
  <li>pk="None" or None or "null"  - parser complains that pk should be integer</li>
  <li>remove "pk" attribute - parser complains that attribute is mandatory</li>
  </ul>
  
  <p>In Django <a href="http://www.djangoproject.com/documentation/0.96/models/serializers/" rel="nofollow noreferrer">Serialization</a> article there is an example how to deserialize from JSON with null "pk".</p>
  
  <pre><code># You can easily create new objects by deserializing data with an empty PK
  # (It's easier to demo this with JSON...)
  &gt;&gt;&gt; new_author_json = '[{"pk": null, "model": "serializers.author", "fields": {"name": "Bill"}}]'
  &gt;&gt;&gt; for obj in serializers.deserialize("json", new_author_json):
  ...     obj.save()
  </code></pre>
  
  <p>(It's actually for 0.96, but I'm assuming it should work for 1.* also)</p>
  
  <p>So in JSON pk can be null but in XML it complains. How to set pk to null for XML?</p>
  
  <p>Thanks</p>