Ticket #10784: 10784-admin-list_editable-ordering-validation.diff

File 10784-admin-list_editable-ordering-validation.diff, 872 bytes (added by Will Hardy, 15 years ago)

Alternative to fixing problem: Admin validation to prevent the situation arising.

  • django/contrib/admin/validation.py

     
    9191                raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
    9292                    "field, '%s', which isn't editable through the admin."
    9393                    % (cls.__name__, idx, field_name))
     94            if not field.unique and (field_name in (cls.ordering or opts.ordering or ())):
     95                raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a "
     96                    "non-unique field, '%s', which controls the ordering of "
     97                    "items in the admin."
     98                    % (cls.__name__, idx, field_name))
    9499
    95100    # search_fields = ()
    96101    if hasattr(cls, 'search_fields'):
Back to Top