﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10808	Multiple inheritance (model-based) broken for __init__ of common fields in diamond inheritance	mikemintz	Malcolm Tredinnick	"I am using the latest version of Django SVN r10558.

My models are:

{{{
class Restaurant(models.Model):
    name = models.CharField(max_length=255)

class Bar(Restaurant):
    min_age = models.IntegerField()

class Pizzeria(Restaurant):
    specialty = models.CharField(max_length=255)

class PizzeriaBar(Bar, Pizzeria):
    pizza_bar_specific_field = models.CharField(max_length=255)
}}}

This yields the following inheritance diagram:
{{{
    Model
      |
  Restaurant
 /         \
Bar     Pizzeria
 \         /
 BarPizzeria
}}}

My problem is that setting the name field in !PizzeriaBar.!__init!__ does not work.

{{{
>>> p = PizzeriaBar(name=""Michaels"", min_age=21, specialty=""Cheese"", pizza_bar_specific_field=""Doodle"")
>>> print (p.name, p.min_age, p.specialty, p.pizza_bar_specific_field)
('', 21, 'Cheese', 'Doodle')

>>> p = PizzeriaBar()
>>> p.name = ""Michaels""
>>> p.min_age = 21
>>> p.specialty = ""Cheese""
>>> p.pizza_bar_specific_field = ""Doodle""
>>> print (p.name, p.min_age, p.specialty, p.pizza_bar_specific_field)
('Michaels', 21, 'Cheese', 'Doodle')
}}}

So this problem only comes up when you are using multiple inheritance, and you set a field defined in a shared superclass of the current model's superclasses (i.e., diamond inheritance). I know diamond inheritance isn't great to use, but it's useful in my application (in which most models inherit from a top-level Item model), and since it works when using setattr, it seems like it should be possible to work in !__init!__."	Bug	closed	Database layer (models, ORM)	dev	Normal	invalid		shaun@…	Accepted	1	0	0	1	0	0
