diff options
Diffstat (limited to 'save_carefully.py')
-rw-r--r-- | save_carefully.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/save_carefully.py b/save_carefully.py new file mode 100644 index 0000000..1631618 --- /dev/null +++ b/save_carefully.py @@ -0,0 +1,10 @@ +def save(objectType, lookupAttribs={}, nonLookupAttribs={}):
+
+ instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs)
+
+ if not created and not instance.new_since_parsing:
+ for k, v in nonLookupAttribs.items(): #overwrite the existing attributes from the logbook text (except date and title)
+ setattr(instance, k, v)
+ instance.save()
+
+ return instance
\ No newline at end of file |