From 408e3b9ce454f24e73854ca9416c1c135088d2ea Mon Sep 17 00:00:00 2001 From: vincent porte Date: Thu, 8 Aug 2024 10:37:18 +0200 Subject: [PATCH] pythonic --- lacommunaute/forum/forms.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lacommunaute/forum/forms.py b/lacommunaute/forum/forms.py index 599f60a1..82eab31c 100644 --- a/lacommunaute/forum/forms.py +++ b/lacommunaute/forum/forms.py @@ -2,7 +2,6 @@ from django import forms from django.conf import settings -from django.core.exceptions import ObjectDoesNotExist from django.forms import CharField, CheckboxSelectMultiple, ModelMultipleChoiceField from taggit.models import Tag @@ -49,11 +48,8 @@ class ForumForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - try: - if self.instance.pk: - self.fields["tags"].initial = self.instance.tags.all() - except ObjectDoesNotExist: - pass + if self.instance.pk: + self.fields["tags"].initial = self.instance.tags.all() def save(self, commit=True): forum = super().save(commit=False)