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')
- [Django]-How to have nested url namespaces with a dynamic first part in Django
- [Django]-RequestFactory & reverse with pk (must be called with either an object pk or a slug)
- [Django]-Speed up often used Django random query
- [Django]-'web:' is not recognised as an internal or external command
1👍
do this :
return redirect(reverse('ProductSingle',product.slug) + '#SectionInWebsite')
- [Django]-How wrap a FormWizard in a View?
- [Django]-Django with IronPython and VS2010?
- [Django]-Websocket connection not working in Django Channels ('WebSocket connection to 'ws://localhost:8000/ws/board/7/' failed:')
- [Django]-Django: Passing object from template to views
Source:stackexchange.com