Hi,

I have a base model A and two models B and C inheriting from the base
model. I'm using django-polymorphic[1] since it very conveniently
returns a list of B and C when querying on A. The requirement came up
that model C needs a GeometryField, and now I'm stuck. Both GeoDjango
and django-polymorphic define their own managers, and they both
require their manager to be the default manager (polymorphic
explicitly, GeoDjango throws exceptions when trying to access the geo
field if GeoManager isn't the default manager).

I almost got it working with this code:

    class CombinedQuerySet(GeoQuerySet, PolymorphicQuerySet):
        pass

    class CombinedManager(GeoManager, PolymorphicManager):
        def get_query_set(self):
            return CombinedQuerySet(self.model, using=self._db)

    class A(models.Model):
        objects = CombinedManager()

With this code, GeoDjango only complains ('String or unicode input
unrecognized as WKT EWKT, and HEXEWKB.') on queries like

    A.objects.all()[0].geo_field # first elem is of type 'C'

while this query works:

    C.objects.all()[0].geo_field

So, is it possible to combine these two managers so that both their
features work?

Kind regards,
Benjamin

[1]: https://github.com/bconstantin/django_polymorphic

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to