Re: [Django] #10808: Multiple inheritance (model-based) broken for __init__ of common fields in diamond inheritance

18 views
Skip to first unread message

Django

unread,
May 5, 2011, 2:45:14 PM5/5/11
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner: mtredinnick
Type: Bug | Status: new
Milestone: | Component: Database layer
Version: SVN | (models, ORM)
Resolution: | Severity: Normal
Triage Stage: Accepted | Keywords:
Needs documentation: 0 | Has patch: 1
Patch needs improvement: 1 | Needs tests: 0
| Easy pickings: 0
-------------------------------------+-------------------------------------
Changes (by patchhammer):

* needs_better_patch: 0 => 1
* easy: => 0


Comment:

10808b-14404.diff fails to apply cleanly on to trunk

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

Django

unread,
Sep 5, 2012, 3:30:06 PM9/5/12
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner:
Type: Bug | mtredinnick
Component: Database layer | Status: new
(models, ORM) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by lsaffre):

The following workaround uses the class_prepared signal to removes any
duplicate fields from `_meta._field_cache`:


{{{
def on_class_prepared(signal,sender=None,**kw):
cache = []
field_names = set()
for f,m in model._meta._field_cache:
if f.attname not in field_names:
field_names.add(f.attname)
cache.append( (f,m) )
model._meta._field_cache = tuple(cache)
model._meta._field_name_cache = [x for x, _ in cache]

models.signals.class_prepared.connect(on_class_prepared)
}}}

Works for me and has the advantage of not needing to patch Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/10808#comment:18>

Django

unread,
Aug 6, 2015, 1:03:54 PM8/6/15
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner:
| mtredinnick
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

Closed #17232 as a duplicate.

--
Ticket URL: <https://code.djangoproject.com/ticket/10808#comment:19>

Django

unread,
Oct 7, 2015, 2:11:33 PM10/7/15
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner:
| mtredinnick
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* resolution: => invalid


Comment:

Closing as invalid because the provided models don't validate:
{{{
PizzeriaBar: (models.E005) The field 'restaurant_ptr' from parent model
'polls.bar' clashes with the field 'restaurant_ptr' from parent model
'polls.pizzeria'.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/10808#comment:20>

Django

unread,
Sep 3, 2023, 8:55:56 PM9/3/23
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner: Malcolm
| Tredinnick
Type: Bug | Status: new
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ElectronicRU):

* status: closed => new
* resolution: invalid =>


Comment:

I'm experiencing the bug with trying to inherit from wagtail's Page and
Collection models.

Closing the ticket about the models being invalid because provided models
were invalid doesn't look like a sound decision, so reopening.

--
Ticket URL: <https://code.djangoproject.com/ticket/10808#comment:21>

Django

unread,
Sep 3, 2023, 11:27:38 PM9/3/23
to django-...@googlegroups.com
#10808: Multiple inheritance (model-based) broken for __init__ of common fields in
diamond inheritance
-------------------------------------+-------------------------------------
Reporter: mikemintz | Owner: Malcolm
| Tredinnick
Type: Bug | Status: closed

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Please don't reopen old tickets without providing new details. We cannot
accept or investigate reports based on model definitions that are not
supported.

--
Ticket URL: <https://code.djangoproject.com/ticket/10808#comment:22>

Reply all
Reply to author
Forward
0 new messages