dimanche 22 mars 2015

How can I modify the class for a button in a django widget form?

I'm trying to set the class for a form widget. I have:



<form action="{% url "list" %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<p>{{ form.non_field_errors }}</p>
<p>{{ form.input.label_tag }} {{ form.input.help_text }}</p>
<p>
{{ form.input.errors }}
{{ form.input }}
</p>
<p>{{ form.non_field_errors }}</p>
<p>{{ form.itinerary.label_tag }} {{ form.itinerary.help_text }}</p>
<p>
{{ form.itinerary.errors }}
{{ form.itinerary }}
</p>
<p><input class="button-primary" type="submit" value="Upload" /></p>
</form>


and it looks like


I attempted to use django tweak tools when I tried googling to find a solution for my problem. I modified the code to be like this too see how it would change:



<form action="{% url "list" %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
{% load widget_tweaks %}
<p>{{ form.non_field_errors }}</p>
<p>{{ form.input.label_tag }} {{ form.input.help_text }}</p>
<p>
{{ form.input.errors }}
{{ form.input }}
{% render_field form.input class="button" %}
</p>
<p>{{ form.non_field_errors }}</p>
<p>{{ form.itinerary.label_tag }} {{ form.itinerary.help_text }}</p>
<p>
{{ form.itinerary.errors }}
{{ form.itinerary }}
</p>
<p><input class="button-primary" type="submit" value="Upload" /></p>
</form>


and that looks like


It applies the class to the whole widget, and it turns the whole widget into a button.


So how can I apply the class to just the button in the widget?


Aucun commentaire:

Enregistrer un commentaire