slug in redirect django

Solutions on MaxInterview for slug in redirect django by the best coders in the world

showing results for - "slug in redirect django"
Michael
03 Apr 2020
1from django.shortcuts import get_object_or_404, redirect
2
3def post(request, slug, post_id):
4    obj = get_object_or_404(Post, pk=post_id)
5    if obj.slug != slug:
6        return redirect('post', slug=obj.slug, post_id=obj.pk)
7
similar questions
queries leading to this page
slug in redirect django