{{{
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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/21297#comment:1>
* status: new => closed
* resolution: => needsinfo
Comment:
I don't think the use case (subclassing without any additional fields) is
advisable without using
[https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models
proxy models] -- if there are no fields on `SubModel`, then there's no
reason to join the `sub_model` table. Please reopen this doesn't work for
you.
--
Ticket URL: <https://code.djangoproject.com/ticket/21297#comment:2>