From 2066511e57cbca58d031a7ae57f1317ed130dfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Schl=C3=B6gl?= Date: Tue, 17 Dec 2024 11:57:08 +0100 Subject: [PATCH] feat(generic): add `uri_set` method to GenericModel --- apis_core/generic/abc.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apis_core/generic/abc.py b/apis_core/generic/abc.py index 7610b7cca..740508e62 100644 --- a/apis_core/generic/abc.py +++ b/apis_core/generic/abc.py @@ -218,3 +218,12 @@ def duplicate(self): return newobj duplicate.alters_data = True + + def uri_set(self): + ct = ContentType.objects.get_for_model(self) + return ( + ContentType.objects.get(app_label="apis_metainfo", model="uri") + .model_class() + .objects.filter(content_type=ct, object_id=self.id) + .all() + )