From 0a29319e2d7d8a3eb190b3596bb9e7942dc28d3e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 15 Oct 2025 19:01:43 +0200 Subject: ♻️ django 3.2 - new version of libraries: fix errors and deprecation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/admin.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ishtar_common/admin.py') diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 5775eada8..dbce4670f 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -2539,11 +2539,16 @@ class JsonContentTypeFormMixin(object): exclude = [] def __init__(self, *args, **kwargs): - super(JsonContentTypeFormMixin, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) choices = [] - for pk, label in self.fields["content_type"].choices: - if not pk: - choices.append((pk, label)) + for choice, label in self.fields["content_type"].choices: + if not choice: + choices.append(('', label)) + continue + try: + pk = int(choice.value) + except ValueError: + choices.append(('', label)) continue ct = ContentType.objects.get(pk=pk) model_class = ct.model_class() -- cgit v1.2.3