GeoDjango 1.2 import error on gqn

10 views
Skip to first unread message

guillaume

unread,
Jun 15, 2010, 5:23:53 AM6/15/10
to geodjango
Hi,

I'm having trouble setting up a GeoDjango app with the last trunk
version (1.2.1).
After declaring some geo model, syncdb fires :
from django.contrib.gis.db.backend import SpatialBackend, gqn
ImportError: cannot import name gqn

I've found gqn into django.contrib.gis.db.backends.util, but couldn't
manage to solve the import problem.

Any hint ?

Thanks

Guillaume

Guillaume Sueur

unread,
Jun 15, 2010, 10:34:02 AM6/15/10
to geodjango

I've found something. There seem to be a conflict in :
django/contrib/gis/db/models
between
fields.py
and
fields/__init__.py

renaming the fields directory to fields_bak solved the issue...

Le 15/06/2010 11:23, guillaume a ï¿œcrit :

Justin Bronn

unread,
Jun 15, 2010, 10:40:48 AM6/15/10
to geod...@googlegroups.com
On 6/15/10 4:23 AM, guillaume wrote:
> I've found gqn into django.contrib.gis.db.backends.util, but couldn't
> manage to solve the import problem.

The problem is that you've got some vestigal code from a previous
release in your Django tree --
`django/contrib/gis/db/models/fields/__init__.py` is no longer used, and
the module was renamed to `fields.py`.

This typically occurs when upgrading via SVN as it leaves the directory
when doing `svn update`.

-Justin

Guillaume Sueur

unread,
Jun 15, 2010, 10:44:06 AM6/15/10
to geod...@googlegroups.com
ok, that must be it. So I delete the fields folder.
Thanks Justin


Le 15/06/2010 16:40, Justin Bronn a ï¿œcrit :

Guillaume Sueur

unread,
Jun 15, 2010, 10:54:28 AM6/15/10
to geod...@googlegroups.com
Me again, with another problem.

I have a simple geographic model designed to store polygons :

class SpatialHits(models.Model):
month = models.IntegerField("Mois")
year = models.IntegerField("Annï¿œe")
layer = models.ForeignKey(Layer)
geom = models.PolygonField(dim=2)
objects = models.GeoManager()
class Meta:
verbose_name_plural = "Bounding boxes"
def __unicode__(self):
return self.name

Then I want to add an objects to it :
I retrieve a bbox and make a polygon from it:
poly_obj = Polygon.from_bbox(vals)
# add the object
my_bbox = SpatialHits(layer=my_layer, month=now.month, year=now.year,
geom=poly_obj)
my_bbox.save()

the system then complains about the object conflicting with the 2 dims
geometry constraint. If I drop that constraint, the records are
definitely 3D. If i check poly_obj.wkt out before creating the new
object, it is a normal 2D object.
I think something is transforming it to a 3D object on the new record
initialization, but can't figure out how.

Thanks for your clues,

Regards,

Guillaume

Reply all
Reply to author
Forward
0 new messages