#12304: modelForm/unique_together error 'Foo bar with this None and None already
exists.'
----------------------------------------+-----------------------------------
 Reporter:  johnsmith                   |       Owner:  nobody    
   Status:  new                         |   Milestone:            
Component:  Forms                       |     Version:  1.1       
 Keywords:  ModelForm, unique_together  |       Stage:  Unreviewed
Has_patch:  0                           |  
----------------------------------------+-----------------------------------
 "Foo bar with this None and None already exists."

 Try to save a combination of foo and bar that already exists using the
 form below and the
 error message says "this None and None", comment out the field
 overrides and there's no problem.
 Not sure whether the problem is with unique_together or ModelForm.


 Models
 {{{
 class Foo(models.Model):
     f = models.IntegerField(unique=True)
     def __unicode__(self):
         return 'Foo with f = %d' % self.f

 class Bar(models.Model):
     b = models.IntegerField(unique=True)
     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'),)
 }}}


 Form
 {{{
 class FooBarForm(forms.ModelForm):
     foo = forms.ModelChoiceField(Foo.objects.all()) # comment this line
 out an the error message is correct
     bar = forms.ModelChoiceField(Bar.objects.all()) # comment this line
 out an the error message is correct

     class Meta:
         model = FooBar
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12304>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.


Reply via email to