[Django]-How to append string in the end of Django redirect in view?

1👍

This worked for me (I had to use different names on my machine, but it should work):

# views.py
return redirect('{}#sectionInWebsite'.format(reverse('ProductSingle', kwargs={'product_slug':product.slug})))

That is, assuming your urls.py has something like this:

# urls.py
...
path('ProductSingle/<str:product_slug>', views.ProductSingle, name='ProductSingle'),
...

This is just a variation of the answer provided here, applied to your situation.

1👍

Maybe this can help you, using reverse.

return redirect(reverse('ProductSingle', product.slug) + '#SectionInWebsite')

1👍

do this :

return redirect(reverse('ProductSingle',product.slug) + '#SectionInWebsite')

Leave a comment