On Thu, Nov 26, 2009 at 12:37 PM, cerberos <pe...@whywouldwe.com> wrote:
> I have a model that has two fields (Django 1.1.1) > > class FooBar(models.Model): > foo = models.ForeignKey('Foo') > bar = models.ForeignKey('Bar') > > class Meta: > unique_together = (('foo','bar'),) > > When is_valid is called in my view and the combination of fields > already exists (eg unique_together is false) the error returned is > "Foo bar with this None and None already exists." > > "None and None" seems like a bug to me, but I'm not sure. > > Using these models (making up my own specs for Foo and Bar since they are referenced but not described by what you posted): class Foo(models.Model): f = models.IntegerField() def __unicode__(self): return 'Foo with f = %d' % self.f class Bar(models.Model): b = models.IntegerField() def __unicode__(self): return 'Bar with b = %d' % self.b class FooBar(models.Model): foo = models.ForeignKey('Foo') bar = models.ForeignKey('Bar') class Meta: unique_together = (('foo','bar'),) and the admin app, the message I get when attempting to add a FooBar that violates the unique constraint is: Foo bar with this Foo and Bar already exists. So there seems to be something left out of the description of what you are doing that may be leading to the None and None in your message, but I'm not sure what that might be. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.