mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[gis] Tweaked layermapping to note updates to unique'd models.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7389 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2efc34dc5e
commit
f273b371a4
@ -597,6 +597,7 @@ class LayerMapping(object):
|
|||||||
stream.write('Ignoring Feature ID %s because: %s\n' % (feat.fid, msg))
|
stream.write('Ignoring Feature ID %s because: %s\n' % (feat.fid, msg))
|
||||||
else:
|
else:
|
||||||
# Constructing the model using the keyword args
|
# Constructing the model using the keyword args
|
||||||
|
is_update = False
|
||||||
if self.unique:
|
if self.unique:
|
||||||
# If we want unique models on a particular field, handle the
|
# If we want unique models on a particular field, handle the
|
||||||
# geometry appropriately.
|
# geometry appropriately.
|
||||||
@ -605,6 +606,7 @@ class LayerMapping(object):
|
|||||||
# the unique model.
|
# the unique model.
|
||||||
u_kwargs = self.unique_kwargs(kwargs)
|
u_kwargs = self.unique_kwargs(kwargs)
|
||||||
m = self.model.objects.get(**u_kwargs)
|
m = self.model.objects.get(**u_kwargs)
|
||||||
|
is_update = True
|
||||||
|
|
||||||
# Getting the geometry (in OGR form), creating
|
# Getting the geometry (in OGR form), creating
|
||||||
# one from the kwargs WKT, adding in additional
|
# one from the kwargs WKT, adding in additional
|
||||||
@ -624,7 +626,7 @@ class LayerMapping(object):
|
|||||||
# Attempting to save.
|
# Attempting to save.
|
||||||
m.save()
|
m.save()
|
||||||
num_saved += 1
|
num_saved += 1
|
||||||
if verbose: stream.write('Saved: %s\n' % m)
|
if verbose: stream.write('%s: %s\n' % (is_update and 'Updated' or 'Saved', m))
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
raise
|
raise
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user