﻿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
24156	inherited manytomany.all() empty when 2 or more inherited model from abstract one	Timothée Mazzucotelli	Andriy Sokolovskiy	"If you set a ManyToMany field in an abstract model, and then you use this model as inheritance for 2 or more sub-models (non-abstracts), you will not be able to use submodel_instance.manytomany_field.all() anymore (actually it will work but return an empty list).

Here is an example of code producing this ""bug"":

{{{
from django.db import models


class Something(models.Model):
    name = models.CharField('something', max_length=255)
    
    def __unicode__(self):
        return self.name


class AbstractModel(models.Model):
    manythings = models.ManyToManyField(
        Something, verbose_name='manythings', related_name='+',
        blank=True, null=True)

    class Meta:
        abstract = True


class BugModel1(AbstractModel):
    custom1 = models.CharField('custom_field', max_length=255)


class BugModel2(AbstractModel):
    custom2 = models.CharField('custom_field', max_length=255)
}}}

When you add a Something instance to the manythings field of a BugModelN instance, it is correctly added (I was able to confirm this by trying to delete the object through admin interface: it lists the foreign key related object that will be deleted on cascade), but when you want to get it through the all() method of the manytomany field, it returns an empty list.

I am not sure if it is a bug since I was not able to get any raised error or else through debug. Maybe a voluntary behavior or a forgotten use case?

(Django 1.7.3)"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	inherit asbtract manytomanys	me@…	Ready for checkin	1	0	0	0	0	0
