I'm trying to add a comment form in a DetailView in Django and I don't know how to approach it. I've been able to do it with a function based view but I don't know how to start using a class based view.
My views.py for the DetailView :
class BusinesDetaiView(DetailView):
queryset = Business.objects.all()
Any suggestions?
Thanks!
Create a FormView template and put in the action of the form the url to the view
views:
from django.views.generic import FormView
class CommentForm(FormView):
model = CommentModel
form_class = CommentModelForm
html:
<form method="post" action="{% url "commentform_create" %}">
{{ form }}
</form>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.