Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#7353 closed (invalid)

Add manipulator fails when unique together fields added

Reported by: m.gajda@… 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)

correct-field-lookup.patch (686 bytes ) - added by m.gajda@… 16 years ago.

Download all attachments as: .zip

Change History (9)

by m.gajda@…, 16 years ago

Attachment: correct-field-lookup.patch added

comment:1 by anonymous, 16 years ago

Cc: m.gajda@… added
Has patch: set
Keywords: admin maniuplator add iexact fail added
Summary: Add manipulator failsAdd manipulator fails when unique together fields added

comment:2 by James Bennett, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #4705.

comment:3 by James Bennett, 16 years ago

Component: Core frameworkAdmin interface
Keywords: nfa-blocker added
Resolution: duplicate
Status: closedreopened
Triage Stage: UnreviewedAccepted
Version: SVNnewforms-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 James Bennett, 16 years ago

Patch needs improvement: set

comment:5 by Marc Garcia, 16 years ago

milestone: 1.0 alpha

comment:6 by anonymous, 16 years ago

Cc: cmawebsite@… added

comment:7 by Brian Rosner, 16 years ago

Resolution: invalid
Status: reopenedclosed

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.

comment:8 by Jacob, 13 years ago

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

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