Opened 5 years ago

Closed 5 years ago

#19956 closed Uncategorized (invalid)

Manual PrimaryKey isn't updated after save, create

Reported by: grzesiof@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords: primary_key
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


The regular auto id field is updated after the object is saved to the database. This doesn't happen when using manual primary keys:

class A(models.Model): pass
class B(models.Model):
    id = models.IntegerField(primary_key=True)

A.objects.create().pk # 1
B.objects.create().pk # None

The pk value is only updated for auto fields:

Change History (1)

comment:1 Changed 5 years ago by grzesiof@…

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top