Ticket #9218: key-error-on-empty-pk-field-in-forms-fix-test.patch

File key-error-on-empty-pk-field-in-forms-fix-test.patch, 861 bytes (added by romke <rombar@…>, 16 years ago)

test for fix

  • regressiontests/forms/models.py

     
    2424class FileForm(django_forms.Form):
    2525    file1 = django_forms.FileField()
    2626
     27class PKNotIDModel(models.Model):
     28  testing = models.CharField(max_length=20, primary_key=True)
     29
    2730__test__ = {'API_TESTS': """
    2831>>> from django.forms.models import ModelForm
    2932>>> from django.core.files.uploadedfile import SimpleUploadedFile
     
    7376datetime.date(1969, 4, 4)
    7477>>> instance_form.initial['value']
    757812
     79
     80# Test for primary_key not named 'id'
     81>>> class TestForm(ModelForm):
     82...   class Meta:
     83...     model = PKNotIDModel
     84...     fields = ('testing',)
     85>>> form = TestForm({u'testing': u''})
     86>>> form.is_valid()
     87False
    7688"""}
Back to Top