nitely / Spirit

Spirit is a modern Python based forum built on top of Django framework
http://spirit.readthedocs.io
MIT License
1.16k stars 334 forks source link

Integration with django_crispy_forms? #275

Closed grwhumphries closed 5 years ago

grwhumphries commented 5 years ago

I've tried a few times to get crispy forms working here, but it's not quite clear how to do it. Presumably it's something to do with /templates/spirit/_form.html?

I've tried this:

{% load crispy_forms_tags %}

{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}

{{ form.non_field_errors|crispy }}
{% for field in form.hidden_fields %}
{{ field.errors }}
{{ field }}
{% endfor %}

{% for field in form.visible_fields %}
<div class="field">
    {{ field.label_tag }}
    {{ field.errors }}
    {{ field }}
    {{ field.help_text }}
</div>
{% endfor %}

But no styling occurring.

Any thoughts? Thanks!

nitely commented 5 years ago

Never used crispy forms. But I'm guessing you must apply it to the whole form:

{% load crispy_forms_tags %}
{% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
{{ form|crispy }}
<p>This is being overriden</p>

Make sure to override the right template.

nitely commented 5 years ago

/templates/spirit/_form.html is a generic form used by all Spirit forms, so it seems like the right place.