Opened 8 years ago

Closed 8 years ago

Last modified 5 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: UI/UX:


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/", 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@… 8 years ago.

Download all attachments as: .zip

Change History (9)

Changed 8 years ago by m.gajda@…

Attachment: correct-field-lookup.patch added

comment:1 Changed 8 years ago by anonymous

Cc: m.gajda@… added
Has patch: set
Keywords: admin maniuplator add iexact fail added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Summary: Add manipulator failsAdd manipulator fails when unique together fields added

comment:2 Changed 8 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Duplicate of #4705.

comment:3 Changed 8 years ago by James Bennett

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 Changed 8 years ago by James Bennett

Patch needs improvement: set

comment:5 Changed 8 years ago by Marc Garcia

milestone: 1.0 alpha

comment:6 Changed 8 years ago by anonymous

Cc: cmawebsite@… added

comment:7 Changed 8 years ago by Brian Rosner

Resolution: invalid
Status: reopenedclosed

I asked a question about this ticket over on django-dev mailing list ( 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 Changed 5 years ago by Jacob

milestone: 1.0 alpha

Milestone 1.0 alpha deleted

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