Hello All,
I have a Settlement model consisting of name and the geometry (polygon
field) of a settlement. I am trying to import a shape file like this:
from django.contrib.gis.gdal import DataSource
from maps.models import MapFile
from settlements.models import Settlement
mf = MapFile.objects.get(id=11)
ds = DataSource(mf.file.path)
for layer in ds:
for f in layer:
settlement = Settlement(name=.get('NAME'),
geometry=f.geom.wkt)
settlement.save()
But only one settlement instance is created and then on the second
iteration on the layer I get a:
"ProgrammingError: current transaction is aborted, commands ignored
until end of transaction block"
Funny that, I can import every feature from the django shell if I
select a feature manually like:
f = ds[0][0]
settlement = Settlement(name=f.get('NAME'),
geometry=f.geom.wkt)
settlement.save()
To import another, I must exit and re-enter the django shell,
otherwise I get the same error.
I couldn't think of any explanation of this behavior. Can it be about
the thing mentioned about the shape files' MULTIPOLYGON issue
mentioned here?:
http://geodjango.org/docs/tutorial.html
Thanks for any ideas.
-- omat