【发布时间】:2021-01-16 16:03:47
【问题描述】:
这是我的观点.py
from django.shortcuts import render
from django.views.generic import ListView
from .models import Post
class HomePageView(ListView):
model = Post
template_name = 'home.html'
from django.views.generic import ListView, CreateView
from django.urls import reverse_lazy
from .forms import PostForm
from .models import Post
class HomePageView(ListView):
model = Post
template_name = 'home.html'
class CreatePostView(CreateView): # new
model = Post
form_class = PostForm
template_name = 'post.html'
success_url = reverse_lazy('home')
如何将请求传递给模板渲染方法。使用 POST 方法时,我在 Postman 上收到 csrf 令牌错误
【问题讨论】: