Ticket #7772: fields_and_fields.diff

File fields_and_fields.diff, 2.1 KB (added by Julien Phalip, 16 years ago)

Patch + tests

  • django/django/contrib/admin/validation.py

     
    154154        _check_istuplew('fields', cls.fields)
    155155        for field in cls.fields:
    156156            _check_field_existsw('fields', field)
     157        if cls.fieldsets:
     158            raise ImproperlyConfigured('Both fieldsets and fields are specified in %s.' % cls.__name__)
    157159
    158160    # fieldsets
    159161    if cls.fieldsets: # default value is None
  • django/django/contrib/admin/options.py

     
    143143    radio_fields = {}
    144144    prepopulated_fields = {}
    145145
    146     def __init__(self):
    147         # TODO: This should really go in django.core.validation, but validation
    148         # doesn't work on ModelAdmin classes yet.
    149         if self.fieldsets and self.fields:
    150             raise ImproperlyConfigured('Both fieldsets and fields is specified for %s.' % self.model)
    151 
    152146    def formfield_for_dbfield(self, db_field, **kwargs):
    153147        """
    154148        Hook for specifying the form Field instance for a given database Field
  • django/tests/regressiontests/modeladmin/models.py

     
    337337...     fieldsets = (("General", {"fields": ("name",)}),)
    338338>>> validate(ValidationTestModelAdmin, ValidationTestModel)
    339339
     340>>> class ValidationTestModelAdmin(ModelAdmin):
     341...     fieldsets = (("General", {"fields": ("name",)}),)
     342...     fields = ["name",]
     343>>> validate(ValidationTestModelAdmin, ValidationTestModel)
     344Traceback (most recent call last):
     345...
     346ImproperlyConfigured: Both fieldsets and fields are specified in ValidationTestModelAdmin.
     347
    340348# form
    341349
    342350>>> class FakeForm(object):
Back to Top