summaryrefslogtreecommitdiffstats
path: root/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-06-19 16:39:05 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-06-19 16:39:05 +0100
commitb35a0b0d26303e61e20b320db9358ae425c49933 (patch)
treeb241e1ea5747ed44aeef106b35b36a2685326e42 /utils.py
parent2c469718f60a11c0038ec15fb186eac275509b8b (diff)
downloadtroggle-b35a0b0d26303e61e20b320db9358ae425c49933.tar.gz
troggle-b35a0b0d26303e61e20b320db9358ae425c49933.tar.bz2
troggle-b35a0b0d26303e61e20b320db9358ae425c49933.zip
Fully working dj 1.11.29
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/utils.py b/utils.py
index 329efe5..0c56b73 100644
--- a/utils.py
+++ b/utils.py
@@ -45,14 +45,23 @@ def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}):
defined in core.models.TroggleModel.
"""
- print(" !! - SAVE CAREFULLY Django 1.11.29 ", objectType)
- instance, created = objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
-
+ try:
+ instance, created = objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
+ except:
+ print(" !! - SAVE CAREFULLY ===================", objectType)
+ print(" !! - -- objects.get_or_create()")
+ print(" !! - lookupAttribs:{}\n !! - nonLookupAttribs:{}".format(lookupAttribs,nonLookupAttribs))
+ raise
if not created and not instance.new_since_parsing:
for k, v in list(nonLookupAttribs.items()): #overwrite the existing attributes from the logbook text (except date and title)
setattr(instance, k, v)
- instance.save()
-
+ try:
+ instance.save()
+ except:
+ print(" !! - SAVE CAREFULLY ===================", objectType)
+ print(" !! - -- instance.save()")
+ print(" !! - lookupAttribs:{}\n !! - nonLookupAttribs:{}".format(lookupAttribs,nonLookupAttribs))
+ raise
if created:
logging.info(str(instance) + ' was just added to the database for the first time. \n')