Opened 10 days ago

Last modified 5 days ago

#35551 closed Bug

Unique checks skipped when changing primary key — at Initial Version

Reported by: Csirmaz Bendegúz Owned by: nobody
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I noticed the unique checks are skipped (_perform_unique_checks) when an object's primary key is changed.

Given:

# models.py
class Dummy(models.Model):
    id = models.IntegerField(primary_key=True)

# admin.py
admin.site.register(Dummy)
  1. Create Dummy (1), Dummy (2).
  2. Change Dummy (2)'s Id field -> 1
  3. No error, unique checks skipped
  4. Change Dummy (1)'s Id field -> 3
  5. A new Dummy (1) is created (why?)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top