catching family and kid creation/update exceptions

This commit is contained in:
Serghei Mihai 2014-04-03 16:46:47 +02:00
parent bc733f7089
commit cd94f93081
1 changed files with 13 additions and 3 deletions

View File

@ -120,9 +120,15 @@ class FamilleManager(models.Manager):
setattr(obj, attr, value)
updated = True
if updated:
obj.save()
try:
obj.save()
except Exception, e:
print "Family update error: %s for %s" % (e, row)
except models.ObjectDoesNotExist:
obj = self.create(**params)
try:
obj = self.create(**params)
except Exception, e:
print "Family create error: %s for %s" % (e, row)
for person in (pers1, pers2):
try:
@ -219,7 +225,11 @@ class KidManager(models.Manager):
params.pop('date_naissance')
obj_id = params['id']
family_id = params.pop('famille')
family = Famille.objects.get(pk = family_id)
try:
family = Famille.objects.get(pk = family_id)
except Famille.DoesNotExist:
print "Famille %s for kid %s doesn't exist(%s)" % (family_id, obj_id, row)
continue
params['famille'] = family
try: