AttributeError: 'NoneType' object has no attribute 'attname' (Django) : <p>I have a fairly complex model for which the first call to <code>MyModel.objects.create(**kwargs)</code> fails with</p>

<blockquote>
  <p>AttributeError: 'NoneType' object has no attribute 'attname'</p>
</blockquote>

<p>The stack trace dives down like this (in Django 1.11)</p>

<pre><code>django/db/models/manager.py:85: in manager_method
   return getattr(self.get_queryset(), name)(*args, **kwargs)
django/db/models/query.py:394: in create
   obj.save(force_insert=True, using=self.db)
django/db/models/base.py:807: in save
   force_update=force_update, update_fields=update_fields)
django/db/models/base.py:837: in save_base
   updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
django/db/models/base.py:889: in _save_table
   pk_val = self._get_pk_val(meta)
django/db/models/base.py:644: in _get_pk_val
   return getattr(self, meta.pk.attname)
django/db/models/query_utils.py:114: in __get__
   val = self._check_parent_chain(instance, self.field_name)
django/db/models/query_utils.py:131: in __check_parent_chain
   return getattr(instance, link_field.attname)
</code></pre>

<p>The model definition looks alright to me. I have checked all the parameters of the <code>create</code> call are just what I want them to be.</p>

<p>I'm not keen on stripping down the model to find the problem, because the model is so complex. (All my other models, many of them similar, appear to work fine.)</p>

<p>So what might cause this strange message?</p>
