#30427: Descriptors not accessible for inherited models.
-------------------------------------+-------------------------------------
               Reporter:  Jarek      |          Owner:  nobody
  Glowacki                           |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  master
  layer (models, ORM)                |       Keywords:  inherited
               Severity:  Normal     |  descriptor deferred
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Example:
 {{{
 class Base(models.Model):
     A = 1


 class Inherited(Base):
     A = models.IntegerField(default=0)
     B = models.IntegerField(default=0)
 }}}
 And now take a look at this:
 {{{
 >>> Inherited.A
 1
 >>> Inherited.B
 <django.db.models.query_utils.DeferredAttribute object at 0x110ed5470>
 }}}

 Descriptor `A` is not accessible.
 Behaviour is correct when accessing instance attributes, which is why I
 think this has gone under the radar..

 Real use case:
 We try to apply a `FieldTracker` (from Django Model Utils) onto a custom
 user model:
 {{{
 class User(AbstractBaseUser):
     is_active = models.BooleanField(_('active'), default=True)

     tracker = FieldTracker()
 }}}

 FieldTracker falls over wrapping the `is_active` field, because instead of
 getting a `DeferredAttribute` when accessing `User.is_active`, it gets a
 mouthful of `True`, which is the value assigned to `is_active` in
 `AbstractBaseUser`.

 Happy to submit a failing test and propose a fix if issue is accepted.
 Issue replicated on Django2.1.5, but I suspect it's like this on master
 still..

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30427>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.b42f0112bd9f2e4fac8b55e4e825dc15%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to