django form rendering

I have built a django form, simple extract as follows:

attachuploadediso = forms.BooleanField(label='Attach uploaded ISO', required=False)
detachuploadediso = forms.BooleanField(label='Detach uploaded ISO', required=False)
extractuploadediso = forms.BooleanField(label='Extract uploaded ISO', required=False)

I then render the form in my template as follows:

{% block mainbody %}
<form class = "mf" action="/form/" method="post">{% csrf_token %}
{{ form.errors }}
{{ form.non_field_errors }}
{{ form.label_tag }} {{ form.as_p  }}
<input type="submit" value="Submit" />
{% endblock %}

The checkboxes appear after the label text. Is there a way that check boxes appear in a line so the form looks likes better formatted? Or is there a way I can control the layout of the form better? I have used a form.as_table, but my jquery breaks if I render the form in a table.

So in short, I would like

(label) Attach uploaded ISO.............................(Checkbox)

(label) Detach uploaded ISO............................(Checkbox)

(label) Extract uploaded ISO.............................(Checkbox)

How can I control the layout better when a form gets rendered so the checkboxes are all in a line?

Thanks - Oli


You can render each field separately in the form and control look and feel. Each field has label which can be rendered as {{field.label_tag}} and field input as {{field}}.

More details from Django forms documentation

<form action="/contact/" method="post">
{% for field in form %}
    <div class="fieldWrapper">
        {{ field.errors }}
        {{ field.label_tag }}: {{ field }}
{% endfor %}
<p><input type="submit" value="Send message" /></p>

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.