From e86399fdd5184fca1842667e0f661dce5cb9f797 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Fri, 29 Nov 2024 10:20:05 +0100 Subject: [PATCH] feat(apis_entities): update `create_default_uri` to use generic uri The Uri model now uses a generic foreign key instead of the direct foreign key to the RootObject. This commit updates all occurences of `root_object` to use the generic foreign key instead. --- apis_core/apis_entities/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apis_core/apis_entities/models.py b/apis_core/apis_entities/models.py index 18754dfba..0ca67d20c 100644 --- a/apis_core/apis_entities/models.py +++ b/apis_core/apis_entities/models.py @@ -2,6 +2,7 @@ import re from django.conf import settings +from django.contrib.contenttypes.models import ContentType from django.db.models.signals import post_save from django.dispatch import receiver from django.urls import NoReverseMatch, reverse @@ -102,4 +103,9 @@ def create_default_uri(sender, instance, created, raw, using, update_fields, **k "apis_core:GetEntityGeneric", kwargs={"pk": instance.pk} ) uri = f"{base}{route}" - Uri.objects.create(uri=uri, root_object=instance) + content_type = ContentType.objects.get_for_model(instance) + Uri.objects.create( + uri=uri, + content_type=content_type, + object_id=instance.id, + )