#30543: admin.E108 is raised on fields accessible only via instance.
-------------------------------------+-------------------------------------
     Reporter:  ajcsimons            |                    Owner:  ajcsimons
         Type:  Bug                  |                   Status:  closed
    Component:  Core (System         |                  Version:  master
  checks)                            |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by goblinJoel):

 (I found this thread after already finding the commit that caused this
 problem for me, so this is copied/edited from
 
[https://github.com/django/django/commit/47016adbf54b54143d4cf052eeb29fc72d27e6b1#commitcomment-34636977
 my comment there])

 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
 
[https://github.com/django/django/commit/9f6b704769ba5bc0daafc25340d3dc28b18d8fb1
 from 1.10 on], but I thought I'd note this in case there was some reason
 the behavior I described should be supported.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30543#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.7e05ca6ef682541675fd8c99c15ab0fd%40djangoproject.com.

Reply via email to