#24156: inherited manytomany.all() empty when 2 or more inherited model from
asbtract one
-------------------------------------+-------------------------------------
     Reporter:  Pawamoy              |      Owner:  nobody
         Type:  Bug                  |     Status:  new
    Component:  Database layer       |    Version:  1.7
  (models, ORM)                      |   Keywords:  inherit asbtract
     Severity:  Normal               |  manytomanys
 Triage Stage:  Unreviewed           |  Has patch:  0
Easy pickings:  0                    |      UI/UX:  0
-------------------------------------+-------------------------------------
 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)

--
Ticket URL: <https://code.djangoproject.com/ticket/24156>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.7c2ecb22c7c9e00469ed5167fe28edea%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to