django button function vs aesthetic

14 views
Skip to first unread message

clarkso...@gmail.com

unread,
Mar 9, 2016, 5:46:30 PM3/9/16
to Django users

The following is derived from an old post but I can not seem to get the button to render in the way that I want it to.....

Any help?

I am trying implement bootstrap on an upload button that is on the webpage.

class DocumentForm(forms.Form):
    docfile = forms.FileField(label='Select file')
    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Div(
        HTML('<p>{{ form.docfile.label_tag }} {{ form.docfile.help_text }}</p>'),
            css_class='col-sm-4 col-md-9 col-lg-9',
         ),
       )

I have definitely downloaded crispy forms and installed it in "APPS" and loaded the tags onto the page correctly.

I just want to be able to set a simple "div" to the button nothing more.

My HTML is as follows:

   <form action="{% url "list" %}" method="POST" enctype="multipart/form-data">
    <tr>
        {% csrf_token %}
        <p>{{ form.non_field_errors|crispy }}</p>

        <p>{{ form.docfile.label_tag|crispy }} {{ form.docfile.help_text|crispy }}</p>

        <p>
            {{ form.docfile.errors|crispy }}
            {{ form.docfile|crispy }}
        </p>
    </tr>
   </form>

The error I'm getting is as follows:

    'unicode' object has no attribute 'field'

So overall I'm looking to be able to just assign a simple "div" to the upload button that I have created without perturbing the button's function.

Is there a way to do this via the ordinary tag?:

     { % crispy form %}
Reply all
Reply to author
Forward
0 new messages