Skip to content

Commit

Permalink
pythonic
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Aug 8, 2024
1 parent dcded79 commit cc5ff86
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lacommunaute/forum/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cc5ff86

Please sign in to comment.