Django – Cannot force an update in save() with no primary key.

If all debugging steps lead you nowhere with this problem, make sure you are not deferring any fields on your queryset prior to an insert attempt.

For example, I was calling save() on a recently copied object which initially had a deferred field.

Example:

obj = Object.objects.defer('foo')[0]

<a href="http://obj.id">obj.id</a> = None
obj.save() # triggers error

Leave a Comment