Opened 17 years ago
Closed 17 years ago
#7322 closed (duplicate)
objects = GeoManager() in abstract class fails in subclasses
| Reported by: | anonymous | Owned by: | nobody |
|---|---|---|---|
| Component: | GIS | Version: | gis |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The following class definition produces a subclass without a working objects property.
class FeatureBase(models.Model):
feature_id = models.AutoField(primary_key=True)
objects = django.contrib.gis.db.models.GeoManager()
class Meta:
abstract = True
class LoadFeature(FeatureBase):
class Meta:
db_table = 'load_features'
A simple test (notice no query is actually executed by LoadFeature.objects.all():
from django.db import connection from nbd.loading.models import LoadFeature LoadFeature.objects.all() print connection.queries
This can be fixed by adding objects = django.contrib.gis.db.models.GeoManager() to the subclass. This seems to be a bug, or a critical gap in the documentation.
Note:
See TracTickets
for help on using tickets.
I am not sure of GeoDjango stuff and if I am not wrong this looks similar t #7154. At the current moment abstract models don't allow custom managers.