#7353 closed (invalid)
Add manipulator fails when unique together fields added
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.admin | Version: | newforms-admin |
Severity: | Keywords: | admin maniuplator add iexact fail nfa-blocker | |
Cc: | m.gajda@…, cmawebsite@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Hi, everyone!
Below some code, to ilustrate an issue I found:
class A( models.Model ): foo = models.CharField() class B( models.Model ): x = models.ForeignKey( A ) y = models.ForeignKey( B ) class Meta: unique_together = ( ( x , y ) , )
For this piece of code, after adding some objects for "A" model using admin there is no possibility to add something to model "B' (using this same admin). In this case database backed (PostgreSQL in my case) returns error message worrying about wrong comparison operator used to looking for already added object pair.
It raises this error because it tries to compares "y" field using proper "pk" lookup, but for "x" field it invokes "iexact" lookup method. The second one fails, because it should be used only for strings.
After some code investigation I found some weird pair of assigments in file "django/db/models/manipulators.py", which I changed according to attached patch. Now everything seems to work correctly.
Attachments (1)
Change History (9)
by , 17 years ago
Attachment: | correct-field-lookup.patch added |
---|
comment:1 by , 17 years ago
Cc: | added |
---|---|
Has patch: | set |
Keywords: | admin maniuplator add iexact fail added |
Summary: | Add manipulator fails → Add manipulator fails when unique together fields added |
comment:2 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:3 by , 17 years ago
Component: | Core framework → Admin interface |
---|---|
Keywords: | nfa-blocker added |
Resolution: | duplicate |
Status: | closed → reopened |
Triage Stage: | Unreviewed → Accepted |
Version: | SVN → newforms-admin |
Actually, now I look at it I don't think this is a dupe. And we've got internal code still tripping over it on newforms-admin, so I'm recategorizing.
comment:4 by , 17 years ago
Patch needs improvement: | set |
---|
comment:5 by , 17 years ago
milestone: | → 1.0 alpha |
---|
comment:6 by , 16 years ago
Cc: | added |
---|
comment:7 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
I asked a question about this ticket over on django-dev mailing list (http://groups.google.com/group/django-developers/browse_frm/thread/a2d8baf9b6846649). I am closing this ticket because this appears to have no effect in newforms-admin. The AddManipulator no longer is used in newforms-admin. Please re-open with more specific details on how it is a problem on newforms-admin.
Duplicate of #4705.