📅  最后修改于: 2022-03-11 14:45:12.613000             🧑  作者: Mango
from django.shortcuts import get_object_or_404, redirect
def post(request, slug, post_id):
obj = get_object_or_404(Post, pk=post_id)
if obj.slug != slug:
return redirect('post', slug=obj.slug, post_id=obj.pk)