django-deprecate-fields icon indicating copy to clipboard operation
django-deprecate-fields copied to clipboard

deprecate_field: accessing deprecated field NoneType.<unknown>

Open hvdklauw opened this issue 3 years ago • 1 comments

We started used deprecate-fields and saw this warning in our logs.

Turns out django-fsm uses inspect.getmembers which in turn does a getattr(object, key) where the object is the class, not an instance.

Maybe simply catching the None value at the start would be enough.

hvdklauw avatar Jun 24 '21 12:06 hvdklauw

This can also happen when you add a deprecated field to an admin.ModelAdmin.list_display

Workaround:

To find the problematic model, you can:

  1. put a breakpoint in django_deprecate_fields/deprecate_field.py DeprecatedField.__get__
  2. move up the call stack to django/contrib/adminchecks.py _check_list_display_item
  3. inspect obj

willplaehn avatar Jun 09 '22 00:06 willplaehn