Fixed #10530, #10527: added a couple more validation errors around `list_editable`. Thanks, Florian Apolloner.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10080 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
324eba99cb
commit
4a88785e38
|
@ -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'):
|
||||
|
|
Loading…
Reference in New Issue