#12881: Unique constraint error with model inheritance while ModelForm should
not
validate
---------------------------------------------------+------------------------
Reporter: fgaudin | Owner: nobody
Status: new | Milestone: 1.2
Component: Database layer (models, ORM) | Version: 1.1
Resolution: | Keywords: unique
constraint, ModelForm, inheritance
Stage: Accepted | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Changes (by kmtracey):
* stage: Unreviewed => Accepted
* component: Forms => Database layer (models, ORM)
* milestone: => 1.2
Comment:
Ugh. The model class used for the unique checks is the model class
associated with the form. In the case where this class is derived from
another, the resulting query involves a join of the tables for the derived
and parent models. Thus the unique check is improperly constraining the
unique test in the case where the unique constraint is declared in the
parent class. I think the unique check needs to be made using the model
class where the unique constraint actually came from. I'll attach a patch
that works for the posted test, but I'm not too familiar with all the
model class internals so there well be a more straightforward way to
determine the right class to use for the check.
--
Ticket URL: <http://code.djangoproject.com/ticket/12881#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.