diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-15 19:01:43 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-24 18:32:21 +0200 |
| commit | d949976a9fb9ecf1e366486e604c89c56c02c1f8 (patch) | |
| tree | d52afb87c0b633f28c3f5e58388ac9ecbb40d9ee /ishtar_common/admin.py | |
| parent | c08bab38239171e535e51a2f71230c37d6e84985 (diff) | |
| download | Ishtar-d949976a9fb9ecf1e366486e604c89c56c02c1f8.tar.bz2 Ishtar-d949976a9fb9ecf1e366486e604c89c56c02c1f8.zip | |
♻️ django 3.2 - new version of libraries: fix errors and deprecation warnings
Diffstat (limited to 'ishtar_common/admin.py')
| -rw-r--r-- | ishtar_common/admin.py | 13 |
1 files changed, 9 insertions, 4 deletions
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() |
