1

I'm struggling to understand how to use Django-Widget-Tweaks with a stylesheet. For example, here's my basic form with bunch of CSS classes pulled from my stylesheet - obviously not yet wired up with Django.

<form name="form">
    <div class="md-form-group float-label">
      <input type="email" class="md-input">
      <label>Email</label>
    </div> 
</form>

How should this be used with Django-Widget-Tweaks? I'm presuming it's something like this but I'm struggling to understand where the div classes go...

<div>
    {% load widget_tweaks %}
    {{ form.myform|add_class:"md-form-group float-label md-input" }}
</div>

Thanks!

1 Answers1

1

This is how I do it by using render_field tag. Hope this helps.

{% load widget_tweaks %}
<form name="form">
{% for field in form %}
   <div class="md-form-group float-label">
       {% render_field field class="md-input" %}
       <label>{{ field.label_tag }}</label>
   </div>
{% endfor %}
</form>
Ajmal Noushad
  • 926
  • 7
  • 18