Changes between Version 3 and Version 4 of Ticket #30543


Ignore:
Timestamp:
Jun 5, 2019, 9:10:19 AM (6 years ago)
Author:
ajcsimons
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30543 – Description

    v3 v4  
    1616@admin.register(Thing)
    1717class ThingAdmin(admin.ModelAdmin)
    18   list_display = ['name', 'order']
     18  list_display = ['number', 'order']
    1919}}}
    2020
    2121Under 2.2.1 this raises an incorrect admin.E108 message saying "The value of list_display[1] refers to 'order' which is not a callable...".
    2222Under 2.0.7 django starts up successfully.
    23 If you change 'name' to 'no_name' or 'order' to 'no_order' then the validation correctly complains about those.
     23If you change 'number' to 'no_number' or 'order' to 'no_order' then the validation correctly complains about those.
    2424
    2525The reason for this bug is commit https://github.com/django/django/commit/47016adbf54b54143d4cf052eeb29fc72d27e6b1 which was proposed and accepted as a fix for bug https://code.djangoproject.com/ticket/28490. The problem is while it fixed that bug it broke the functionality of _check_list_display_item in other cases. The rationale for that change was that after field=getattr(model, item) field could be None if item was a descriptor returning None, but subsequent code incorrectly interpreted field being None as meaning getattr raised an AttributeError. As this was done **after** trying field = model._meta.get_field(item) and that failing that meant the validation error should be returned. However, after the above change if hasattr(model, item) is false then we no longer even try field = model._meta.get_field(item) before returning an error. The reason hasattr(model, item) is false in the case of a PositionField is its __get__ method throws an exception if called on an instance of the PositionField class on the Thing model class, rather than a Thing instance.
Back to Top