Opened 11 years ago

Closed 11 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


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
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.

Change History (2)

comment:1 Changed 11 years ago by Thejaswi Puthraya

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.

comment:2 Changed 11 years ago by mrts

Resolution: duplicate
Status: newclosed

Duplicate of #7154.

Note: See TracTickets for help on using tickets.
Back to Top