So I have one detail view and one function in my views.py. So i have included the form in detail view template list_detail.html. and upon posting the form successfully. It redirects to all page(homepage basically). Now I want it to redirect to detailview page which is like this. and for that I need to pass the slug value of that List models specific object. But can build the logic here. I am new to django.
path('list/<slug:slug>/', TheirDetailView.as_view(),name='list_detail'),
path('all',views.all, name='all'),
path('create_comment',views.create_comment, name='create_comment'),
class TheirDetailView(DetailView):
model = List
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
modell = Review.objects.all()
context["modam"] = modell
return context
def create_comment(request):
context = {}
form = ReviewForm(request.POST or None)
if form.is_valid():
form.save()
return redirect('app:all')
else:
context['form'] = form
return render(request, "app/create_comment.html", context)