#21297: CurrentSiteManager returns objects of superclass for models that do not
define any additional fields
-------------------------------+--------------------
     Reporter:  dp@…           |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  contrib.sites  |    Version:  1.5
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 Suppose I have two models, one inheriting the other:


 {{{
 class BaseModel(models.Model):
     title = models.CharField()
     # ...

     objects = models.Manager()
     on_site = CurrentSiteManager()
 }}}


 Then I create a subclass:


 {{{
 class SubModel(BaseModel):
     objects = models.Manager()
     on_site = CurrentSiteManager()

     # ...
 }}}


 Then calling SubModel.on_site.all() returns a QuerySet containing all
 instances of BaseModel on that site. Checking the SQL reveals that that no
 table join to the sub_model table occurs.

 This can be worked around by instead calling
 {{{SubModel.objects.filter(site=settings.SITE_ID)}}}, but I do believe
 this to be a bug.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21297>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/060.dd129287c69f404111ca045b690000b5%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to