to reproduce
{{{
import uuid
from django.db import models
class AwesomeModel(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
x = models.CharField(max_length=10)
def save(self, *args, **kwargs):
if self.pk:
print("we have already a pk set")
return super(AwesomeModel, self).save(*args, **kwargs)
a = AwesomeModel(x='some')
a.save()
we have already a pk set
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24691>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => Documentation
* needs_tests: => 0
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
We should likely document `model._state.adding`. See #24377 for a patch
where we had to adapt the admin.
--
Ticket URL: <https://code.djangoproject.com/ticket/24691#comment:1>
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #31502.
--
Ticket URL: <https://code.djangoproject.com/ticket/24691#comment:2>