﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12361	GIS DB query generates invalid SQL on two joins with the same table	wardi	nobody	"{{{
from django.contrib.gis.db import models
from django.contrib.gis.geos import Point

class TestModel(models.Model):
    objects = models.GeoManager()

    point = models.PointField()

class RefModel(models.Model):
    objects = models.GeoManager()

    test1 = models.ForeignKey(TestModel, related_name=""test1s"")
    test2 = models.ForeignKey(TestModel, related_name=""test2s"")

bool(RefModel.objects.filter(test1__point=Point(1,0), test2__point=Point(2,0)))
}}}

causes a `psycopg2.ProgrammingError: Missing FROM-clause entry for table ""T3""`

If point is a CharField or other non-GIS field there is no error.  There is also no error if I don't use GeoManager instances (which is itself incorrect in this case).
"		closed	GIS	dev		duplicate			Unreviewed	0	0	0	0	0	0
