Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #10530, #10527: added a couple more validation errors around `l…

…ist_editable`. Thanks, Florian Apolloner.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10080 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4a88785e38db53187e585cdfab78abc8166a8a8a 1 parent 324eba9
@jacobian jacobian authored
Showing with 17 additions and 8 deletions.
  1. +17 −8 django/contrib/admin/validation.py
View
25 django/contrib/admin/validation.py
@@ -71,21 +71,30 @@ def validate(cls, model):
raise ImproperlyConfigured("'%s.list_editable' cannot be used "
"without a default ordering. Please define ordering on either %s or %s."
% (cls.__name__, cls.__name__, model.__name__))
- for idx, field in enumerate(cls.list_editable):
+ for idx, field_name in enumerate(cls.list_editable):
try:
- opts.get_field_by_name(field)
+ field = opts.get_field_by_name(field_name)[0]
except models.FieldDoesNotExist:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
- "field, '%s', not defiend on %s." % (cls.__name__, idx, field, model.__name__))
- if field not in cls.list_display:
+ "field, '%s', not defiend on %s."
+ % (cls.__name__, idx, field_name, model.__name__))
+ if field_name not in cls.list_display:
raise ImproperlyConfigured("'%s.list_editable[%d]' refers to "
"'%s' which is not defined in 'list_display'."
- % (cls.__name__, idx, field))
- if field in cls.list_display_links:
+ % (cls.__name__, idx, field_name))
+ if field_name in cls.list_display_links:
raise ImproperlyConfigured("'%s' cannot be in both '%s.list_editable'"
" and '%s.list_display_links'"
- % (field, cls.__name__, cls.__name__))
-
+ % (field_name, cls.__name__, cls.__name__))
+ if not cls.list_display_links and cls.list_display[0] in cls.list_editable:
+ raise ImproperlyConfigured("'%s.list_editable[%d]' refers to"
+ " the first field in list_display, '%s', which can't be"
+ " used unless list_display_links is set."
+ % (cls.__name__, idx, cls.list_display[0]))
+ if not field.editable:
+ raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
+ "field, '%s', which isn't editable through the admin."
+ % (cls.__name__, idx, field_name))
# search_fields = ()
if hasattr(cls, 'search_fields'):
Please sign in to comment.
Something went wrong with that request. Please try again.