old_contents: from django import forms
  
  from blogs.models import Post, Blog
  from comments.models import Comment
  
  
  class FilterForm(forms.Form):
      sort = forms.ChoiceField(choices=(
          ('title', 'Заголовок'),
          ('description', 'Описание')
      ), label='Сортировать по', required=False)
  
      search = forms.CharField(max_length=255, label='Поиск', required=False)
  
  
  class CreatePostForm(forms.ModelForm):
      class Meta:
          model = Post
          fields = ('blog', 'title', 'content',)
  
      def __init__(self, *args, **kwargs):
          user = kwargs.pop('user')
          super(CreatePostForm, self).__init__(*args, **kwargs)
          self.fields['blog'].queryset = Blog.objects.filter(owner=user)
  
  
  class UpdatePostForm(forms.ModelForm):
      class Meta:
          model = Post
          fields = ('title', 'content')
  
  
  class CreateCommentForm(forms.ModelForm):
      class Meta:
          model = Comment
          fields = ('text',)
  
      def __init__(self, *args, **kwargs):
          super(CreateCommentForm, self).__init__(*args, **kwargs)
  
      def is_valid(self):
          return super(CreateCommentForm, self).is_valid()
  
  
  class CreateBlogForm(forms.ModelForm):
      class Meta:
          model = Blog
          fields = ('title', 'description', 'category')
          widgets = {
              'category': forms.SelectMultiple()
          }
  
  
  class UpdateBlogForm(forms.ModelForm):
      class Meta:
          model = Blog
          fields = ('title', 'description', 'category')
          widgets = {
              'category': forms.SelectMultiple()
          }
  
new_contents: from django import forms
  
  from blogs.models import Post, Blog
  from comments.models import Comment
  
  
  class FilterForm(forms.Form):
      sort = forms.ChoiceField(choices=(
          ('title', 'Заголовок'),
          ('description', 'Описание')
      ), label='Сортировать по', required=False)
  
      search = forms.CharField(max_length=255, label='Поиск', required=False)
  
  
  class CreatePostForm(forms.ModelForm):
      class Meta:
          model = Post
          fields = ('blog', 'title', 'content',)
          labels = {
              'blog': 'Блог',
              'title': 'Заголовок',
              'content': 'Текст поста'
          }
  
      def __init__(self, *args, **kwargs):
          user = kwargs.pop('user')
          super(CreatePostForm, self).__init__(*args, **kwargs)
          self.fields['blog'].queryset = Blog.objects.filter(owner=user)
  
  
  class UpdatePostForm(forms.ModelForm):
      class Meta:
          model = Post
          fields = ('title', 'content')
          labels = {
              'title': 'Заголовок поста',
              'content': 'Текст поста'
          }
  
  
  class CreateCommentForm(forms.ModelForm):
      class Meta:
          model = Comment
          fields = ('text',)
          labels = {
              'text': 'Комментарий'
          }
  
      def __init__(self, *args, **kwargs):
          super(CreateCommentForm, self).__init__(*args, **kwargs)
  
      def is_valid(self):
          return super(CreateCommentForm, self).is_valid()
  
  
  class CreateBlogForm(forms.ModelForm):
      class Meta:
          model = Blog
          fields = ('title', 'description', 'category')
          labels = {
              'title': 'Название блога',
              'description': 'Краткое описание блога',
              'category': 'Набор категорий блога'
          }
  
  
  class UpdateBlogForm(forms.ModelForm):
      class Meta:
          model = Blog
          fields = ('title', 'description', 'category')
          labels = {
              'title': 'Название блога',
              'description': 'Краткое описание блога',
              'category': 'Набор категорий блога'
          }
  
subject: Add labels to forms.