0

I was trying to use tailwindcss plugins tailwindcss-forms to style comment forms produced by django comments framework.

tailwindcs-forms requires tailwind styling class to be applied on <input type=""> level.

However, in django comments framework, the HTML template file (form.html for example) has no access to <input type="">, which is automatically produced during template rendering process via template variables such as {{ form.comment }}.

What should I do with this dilemma? whether styling forms produced by django comments framework using tailwindcss-forms is really possible?

Yan Tian
  • 377
  • 3
  • 11

1 Answers1

0

You can render the fields individually. For the comment field it can be given as following :

<textarea name="{{ form.comment.id_for_label }}" cols="40" rows="10" maxlength="3000" id="{{ form.comment.html_name }} required"></textarea>

The class attribute can then be added to the field to perform tailwind styling. Similarly the remaining fields needs to be considered.

It should be noted that there are anti-spam attributes present in the form which should be considered while using custom template : https://django-contrib-comments.readthedocs.io/en/latest/quickstart.html?#notes-on-the-comment-form

Also refer : https://django-contrib-comments.readthedocs.io/en/latest/quickstart.html?#rendering-a-custom-comment-form