CurrentSiteManager returns objects of superclass for sub-models that do not define any additional fields
|Reported by:||dp@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (2)
comment:1 Changed 2 years ago by anonymous
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Summary changed from CurrentSiteManager returns objects of superclass for models that do not define any additional fields to CurrentSiteManager returns objects of superclass for sub-models that do not define any additional fields