Tuesday, October 2, 2012

Re: Django 1.4.1, multiple geometry fields problem

This is puzzling. I'm on 1.4.1 and I have models with two geometric columns, without a hitch.

The only interesting thing I can see is that you are using SRID = settings.4326 on extent. Is that correct?

On Tue, Oct 2, 2012 at 7:52 AM, Jani Tiainen <redetin@gmail.com> wrote:
Hi,

I've several models that contains two geometry fields (following is simplified example):

class NetDiagram(models.Model):
    # Columns
    name = models.CharField(max_length=60, blank=True, null=True)

    location = models.GeometryField(_("Center"), db_column='location', srid=4326, null=True, blank=True)
    extent = models.GeometryField(_("Extent"), db_column='extent', srid=settings.4326, null=True, blank=True)

    objects = models.GeoManager()


Now when trying to save model like that I get:

Traceback (most recent call last):
  File "c:\users\jtiai\work\keycom-dev-std\prj\keycom\keycom_net_diagram\diagram\entity_diagram_builder.py", line 134, in _save_to_database
    netdiagram.save()
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py", line 463, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\base.py", line 551, in save_base
    result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\manager.py", line 203, in _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\query.py", line 1576, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py", line 909, in execute_sql
    for sql, params in self.as_sql():
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\db\models\sql\compiler.py", line 886, in as_sql
    for val in values
  File "C:\Users\jtiai\Work\keycom-dev-std\lib\site-packages\django\contrib\gis\db\backends\oracle\compiler.py", line 25, in placeholder
    param_idx = self.query.columns.index(field.column)
AttributeError: 'InsertQuery' object has no attribute 'columns'


Error is consistent and happens when there is two or more geometry fields on a single model.

Same code worked on 1.3 flawlessly.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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




--
George R. C. Silva

Desenvolvimento em GIS
http://geoprocessamento.net
http://blog.geoprocessamento.net

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

No comments:

Post a Comment