From e0b44aaf151c865c12f8990a3bf55556db32536a Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Wed, 23 Oct 2024 11:41:32 +0200 Subject: [PATCH] feat(generic): add a repr dunder method to the GenericModel This method lets us print more meaningful debug messages without having to add the ID to the str dunder method. --- apis_core/generic/abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apis_core/generic/abc.py b/apis_core/generic/abc.py index c6c7f5444..7b7694d6c 100644 --- a/apis_core/generic/abc.py +++ b/apis_core/generic/abc.py @@ -6,6 +6,9 @@ class GenericModel: + def __repr__(self): + return super().__repr__() + f" (ID: {self.id})" + @classmethod def get_listview_url(cls): ct = ContentType.objects.get_for_model(cls)