title: Get name of primary field of Django model
body: <p>In Django, every model has a pseudo attribute <code>pk</code>, that points to the field that is declared as primary key.</p>
  
  <pre><code>class TestModel(models.Model):
      payload = models.Charfield(max_length=200)
  </code></pre>
  
  <p>In this model, the <code>pk</code> attribute would point to the implicit <code>id</code> field, that is generated if no field is declared to be the primary.</p>
  
  <pre><code>class CustomPK(models.Model)
      primary = models.CharField(max_length=100, primary=True)
      payload = models.Charfield(max_length=200)
  </code></pre>
  
  <p>In this model, the <code>pk</code> attribute would point to the explicit defined primary key field <code>primary</code></p>
  
  <p>So my question is, how can I get the name of the field, that is the primary key?</p>