#10808: Multiple inheritance (model-based) broken for __init__ of common fields in diamond inheritance ------------------------------------------+--------------------------------- Reporter: mikemintz | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- 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!__. -- Ticket URL: <http://code.djangoproject.com/ticket/10808> Django <http://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 -~----------~----~----~----~------~----~------~--~---