Opened 12 years ago

Closed 12 years ago

Last modified 5 years ago

#1503 closed defect (fixed)

model validation does not report duplicate auto-generated "id" column

Reported by: mir@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: magic-removal
Severity: normal Keywords:
Cc: mir@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


This is a complicated case ...

If you set up a model class with a field named "id" and without any primary key, Django will add an AutoField named "ID". This leads to a duplicate field name, producing strange effects (django.db.models.query.find_field will report that there's no "id" field at all ...) which are hard to hunt down.

Change History (2)

comment:1 Changed 12 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [3100]) Fixed #1503 -- Improved model validator to throw an error if a model doesn't manually define a primary key and has a field named 'id', which conflicts with the auto-primary-key convention. Thanks, mir@…

comment:2 Changed 5 years ago by anonymous

Easy pickings: unset
UI/UX: unset
Note: See TracTickets for help on using tickets.
Back to Top