mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 10:07:25 +00:00
Fully working dj 1.11.29
This commit is contained in:
19
utils.py
19
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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user