'PostFormView' object has no attribute 'method'

Я новичок и уже долгое время не могу справится с такого рода ошибками. Вот мой код. Urls.py`

from django.urls import path
from new_blog.views import RegisterView, LoginView, ProfileView, PostFormView
from . import views
urlpatterns = [
    path('', views.post_list, name = 'post_list'),
    path('post/<str:slug>/', views.post_detail, name = 'post_detail'),
    path('register/', RegisterView.as_view(), name = 'register'),
    path('login/', LoginView.as_view(), name = 'login'),
    path('profile/', ProfileView.as_view(), name = 'profile'),
    path('logout/', views.logout_view, name = 'logout'),
    path('create/', PostFormView.as_view(), name = 'post_create' ),]`

views

class PostFormView(forms.ModelForm, TemplateView):
    template_name = 'new_blog/post_form.html'
    class Meta:
        model = Post
        fields =('title', 'slug', 'description', 'body')
    def post(request, self):
        if request.method == 'POST':
            post = Post()
            post.title = request.POST.get('title')
            post.slug = request.POST.get('slug')
            post.description = request.POST.get('description')
            post.body = request.POST.get('body')
            post.author = (User.username)
            post.publish = datetime.datetime.now()
            post.status = 'published'
            post.save()

Ответы (1 шт):

Автор решения: Alioshca Z

В Python слово-указатель self в методах класса всегда ставится на первое место в списке параметров метода. Если я правильно понял проблему, то поменяйте код:

def post(request, self):

замените на

def post(self, request):
→ Ссылка