Too many GeoManager in use?

24 views
Skip to first unread message

Michele Mattioni

unread,
Jan 17, 2013, 6:09:32 AM1/17/13
to geod...@googlegroups.com
Dear all,

this is a very strange question, but I'm kind of stuck and I'm wondering if anyone was in the same situation.

I have a class called Location, of this form

class Location(models.Model):
    name = models.CharField(max_length=32,)
    marker = models.PointField(srid=4326) # the marker
    objects = models.GeoManager()

I have a very long geographical queryset that work properly and return the right result

ItemTemplate.objects.filter(producer__user__profile__location__marker__within=poly)

To make this work, I've patched the UserManager from django, in order to extend from the GeoManager, so geographical queryset can be executed also through the user.

When I than added another class with a ForeignKey to ItemTemplate, I cannot perform this queryset:
Item.objects.filter(item_template__producer__user__profile__location__marker__within=poly)

Note that also the smallest queryset:
Location.objects.filter(marker__within=poly)
does not not work anymore, and I receive the same error
FieldError: Join on field 'marker' not permitted. Did you misspell 'within' for the lookup type?

I was thinking that maybe I'm making too many joins, but I'm not sure this is the real problem.
Got any idea/where to look?

Best,
Michele

Max Demars

unread,
May 10, 2013, 8:51:46 AM5/10/13
to geod...@googlegroups.com
The problem might be when you combined GeoManager and UserManager. That could be tricky. You know sometimes you are not obligated to combine two Manager, you can declare more than one Manager per model without problem.
Reply all
Reply to author
Forward
0 new messages