Opened 7 years ago

Closed 7 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: UI/UX:

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 Changed 7 years ago by thejaswi_puthraya

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #7154.

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