python - How can i make a form using django.contrib.comments.forms? -
python - How can i make a form using django.contrib.comments.forms? -
this form file of django.contrib.comments.forms:
https://github.com/django/django/blob/master/django/contrib/comments/forms.py
i need create object of form , utilize in template. don't want create html form object manually in templates, want reuse contrib.comments.forms.
how can it?
something this. may need modify code depending on how want process form data.
from django.contrib.comments.forms import commentform # views.py dev my_view(request): my_obj = mymodel.objects.get(id=1) form = commentform(my_obj) homecoming render(request, 'comment-template.html', {'form': form}) # comment_template.html <form action="{% comment_form_target %}" method="post"> {% csrf token %} {{ form.as_p }} <input type="submit"> </form> python django forms
Comments
Post a Comment