#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 <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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.