From ff3c99989ed8a024a5510bbe7fd0ac4b625216a4 Mon Sep 17 00:00:00 2001 From: Gytha Ogg Date: Wed, 20 Sep 2023 09:28:59 +0200 Subject: [PATCH] fix(apis_relations): fix entity lookup for multi URI entities primary URI is one that is in the same domain as defined in APIS_BASE_URI in settings. the default value for APIS_BASE_URI is hardcoded to be consistent with the same value used in apis_entities at the time of the creation of the URI object Closes: #221 --- apis_core/apis_relations/forms2.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apis_core/apis_relations/forms2.py b/apis_core/apis_relations/forms2.py index 35b97830a..1717e7188 100644 --- a/apis_core/apis_relations/forms2.py +++ b/apis_core/apis_relations/forms2.py @@ -145,7 +145,14 @@ def load_subj_obj_prop( self.fields["property"].choices = [property_initial_value] other_entity_initial_value = ( - str(Uri.objects.get(root_object=entity_instance_other)), + str( + Uri.objects.filter( + root_object=entity_instance_other, + uri__startswith=getattr( + settings, "APIS_BASE_URI", "http://apis.info/" + ), + ).first() + ), f"db {str(entity_instance_other)}", ) self.fields["other_entity"].initial = other_entity_initial_value