Ticket #10527: list_editable_validation.diff

File list_editable_validation.diff, 2.1 KB (added by Florian Apolloner, 15 years ago)
  • django/contrib/admin/validation.py

    diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py
    index fa6d7e3..4b27439 100644
    a b def validate(cls, model):  
    7171            raise ImproperlyConfigured("'%s.list_editable' cannot be used "
    7272                "without a default ordering. Please define ordering on either %s or %s."
    7373                % (cls.__name__, cls.__name__, model.__name__))
    74         for idx, field in enumerate(cls.list_editable):
     74        for idx, field_name in enumerate(cls.list_editable):
    7575            try:
    76                 opts.get_field_by_name(field)
     76                field = opts.get_field_by_name(field_name)[0]
    7777            except models.FieldDoesNotExist:
    7878                raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
    79                     "field, '%s', not defiend on %s." % (cls.__name__, idx, field, model.__name__))
    80             if field not in cls.list_display:
     79                    "field, '%s', not defiend on %s." % (cls.__name__, idx, field_name, model.__name__))
     80            if field_name not in cls.list_display:
    8181                raise ImproperlyConfigured("'%s.list_editable[%d]' refers to "
    8282                    "'%s' which is not defined in 'list_display'."
    83                     % (cls.__name__, idx, field))
    84             if field in cls.list_display_links:
     83                    % (cls.__name__, idx, field_name))
     84            if field_name in cls.list_display_links:
    8585                raise ImproperlyConfigured("'%s' cannot be in both '%s.list_editable'"
    8686                    " and '%s.list_display_links'"
    87                     % (field, cls.__name__, cls.__name__))
    88                
     87                    % (field_name, cls.__name__, cls.__name__))
     88            if not field.editable:
     89                raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
     90                    "field, '%s', which isn't editable through the admin."
     91                    % (cls.__name__, idx, field_name))
    8992
    9093    # search_fields = ()
    9194    if hasattr(cls, 'search_fields'):
Back to Top