Skip to content

Commit

Permalink
make uri migration more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 27, 2023
1 parent 5e9dac2 commit de308ee
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apis_ontology/management/commands/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ def handle(self, *args, **options):
for result in data["results"]:
print(result["url"])
newuri, created = Uri.objects.get_or_create(uri=result["uri"])
try:
result["root_object"] = RootObject.objects.get(pk=result["entity"]["id"])
for attribute in result:
if hasattr(newuri, attribute):
setattr(newuri, attribute, result[attribute])
except RootObject.DoesNotExist:
pass
if hasattr(result["entity"], "id"):
try:
result["root_object"] = RootObject.objects.get(pk=result["entity"]["id"])
for attribute in result:
if hasattr(newuri, attribute):
setattr(newuri, attribute, result[attribute])
newuri.save()
except RootObject.DoesNotExist:
pass

0 comments on commit de308ee

Please sign in to comment.