#17043: Model subclass field named the same as one of the parent model 
subclasses
clashes
----------------------------------------------+--------------------
     Reporter:  charettes                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 The following model inheritance should raise a warning on model
 validation:
 {{{
 #!python
 from django.db import models

 class A(models.Model):
     pass

 class B(A):
     pass

 class C(A):
     b = models.BooleanField()

 print A.b
 #<django.db.models.fields.related.SingleRelatedObjectDescriptor object at
 0x1b08e10>
 print B.b
 #<django.db.models.fields.related.SingleRelatedObjectDescriptor object at
 0x1b08e10>
 print C.b
 #<django.db.models.fields.related.SingleRelatedObjectDescriptor object at
 0x1b08e10>

 C.objects.create(b=False)
 #ValueError: Cannot assign "False": "C.b" must be a "B" instance.
 }}}

 Took me some time before figuring out what was happening. Feel free to
 rename the ticket with a more descriptive title.

 Is there a reason why the {{{RelatedObjectDescriptor}}} is also added to
 the subclasses of {{{A}}} and not only the parent model? Lets say I have a
 {{{c = C}}} instance, theres no way {{{c.b}}} might return something, only
 {{{a = A}}} might do?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17043>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to