Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #28490 -- Removed unused code in admin.E108 check.
- Loading branch information
Showing
1 changed file
with
20 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47016ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While upgrading from Django 1.11 to 2.2, I found this change causes one of our custom field types to fail system checks when used in an admin's list_display. The dev who made the field had overridden
contribute_to_class()
to assign a descriptor class that raises an AttributeError on__get__()
if no instance is supplied, making the field attribute only accessible from instances and not from the class itself.Previously, this still worked, as
model._meta.get_field(item)
returned true. Now,hasattr()
must also be true.I'm pretty sure I can change our
__get__()
to just return the descriptor in that case, as ImageField's descriptor does, but I thought I'd note this in case there was some reason the behavior I described should be supported.47016ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW all descriptors where changed to
return self if instance is None
in 5ef0c03 and 9f6b704 as raising an attribute error broke introspection (help()
, IDEs).There's a few other places in Django that expects
Model.field_name
to return something for a known defined field.47016ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the response! That's reassuring. I see the FileDescriptor was updated in 1.10, and our field was made before that. I bet the prior dev was following that example.
I also found there is a bug thread for my problem, so I'll copy my comment to there: https://code.djangoproject.com/ticket/30543