Ticket #10363: 10363.diff

File 10363.diff, 1.6 KB (added by k0001, 16 years ago)

fix and tests

  • django/forms/models.py

     
    322322            fail_message = 'created'
    323323        else:
    324324            fail_message = 'changed'
    325         return save_instance(self, self.instance, self._meta.fields, fail_message, commit)
     325        exclude = self._meta.exclude or []
     326        return save_instance(self, self.instance, self._meta.fields,
     327                             fail_message, commit, exclude=exclude)
    326328
    327329    save.alters_data = True
    328330
  • tests/regressiontests/forms/models.py

     
    2929class FileForm(django_forms.Form):
    3030    file1 = django_forms.FileField()
    3131
     32
    3233__test__ = {'API_TESTS': """
    3334>>> from django.forms.models import ModelForm
    3435>>> from django.core.files.uploadedfile import SimpleUploadedFile
     
    7879datetime.date(1969, 4, 4)
    7980>>> instance_form.initial['value']
    808112
     82
     83>>> from django.forms import CharField
     84>>> class ExcludingForm(ModelForm):
     85...     name = CharField(max_length=256)
     86...     class Meta:
     87...         model = Defaults
     88...         exclude = ['name']
     89>>> f = ExcludingForm({'name': u'Hello', 'value': 99, 'def_date': datetime.date(1999, 3, 2)})
     90>>> f.is_valid()
     91True
     92>>> f.cleaned_data['name']
     93u'Hello'
     94>>> obj = f.save()
     95>>> obj.name
     96u'class default value'
     97>>> obj.value
     9899
     99>>> obj.def_date
     100datetime.date(1999, 3, 2)
    81101"""}
Back to Top