I'm going to take a guess that when you "drop one" of them, deleting it, there's still a query going on that might want to refer to the other one, and the to_python fails because that reference doesn't exist anymore.
You might have better luck if you're using a OneToOne or ForeignKey (onetomany), which will let django manage that relationship for you. On Wednesday, December 12, 2012 4:21:59 PM UTC-8, Mike Dewhirst wrote: > > I'm getting an unexpected validation error in Admin which baffles me. > Any hints appreciated ... here is the traceback > > http://dpaste.com/844972/ > > At the bottom of the traceback where the error is raised, the local vars > are ... > > self <django.forms.models.ModelChoiceField object at 0x02414890> > value u'33' > key 'pk' > > When I save the item, it auto-generates many-to-many connections to a > few standard images in the database via a through table. However there > is a rule which says "if ever these two images are connected to an item, > only keep this one and drop that one." > > I use a post-save signal to "drop that one" using ... > > Item_Pictogram.objects.filter(item=instance, pictogram=pic, > via='auto').delete() > > The local var value above being u'33' happens to be the exact pk of the > Item_Pictogram record I want to delete - I checked in Postgres. > > The pk should be an integer but I suppose that's nothing. > > Thanks for any help > > Mike > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/TjN8sz1YkQwJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.