Opened 16 years ago

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

Change History (2)

comment:1 by Thejaswi Puthraya, 16 years ago

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 by mrts, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #7154.

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