Answers for "slug in redirect django"

0

slug in redirect django

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)
Posted by: Guest on September-18-2021

Python Answers by Framework

Browse Popular Code Answers by Language