WebFaction
Community site: login faq

I am using formset in my app.

forms.py

BookFormset = inlineformset_factory(Author, Book, 
    fields=('book_name', 'publisher_name'), extra=1, 
    can_delete=False)

my template for doing is

{{ formset.non_form_errors.as_ul }}
<table id="formset" class="form">
{% for form in formset.forms %}
  {% if forloop.first %}
  <thead><tr>
    {% for field in form.visible_fields %}
    <th>{{ field.label|capfirst }}
    {% endfor %}
  </tr></thead>
  {% endif %}
  <tr class="{% cycle row1,row2 %}">
  {% for field in form.visible_fields %}
    <td>
    {# Include the hidden fields in the form #}
    {% if forloop.first %}
      {% for hidden in form.hidden_fields %}
      {{ hidden }}
      {% endfor %}
    {% endif %}
      {{ field.errors.as_ul }}
      {{ field }}
    </td>
  {% endfor %}
  </tr>
{% endfor %}    
</table>

The fields are displayed in the web page in column wise,but i am expecting it to be in row wise.

Can any one guide me how to do?

see my o/p looks like this

Book name   Publisher name

book_field       Publisher_field

i am expecting it to be like this

Book name   book_field

Publisher name   Publisher_field

Help me please

Thanks

asked 06 Apr '13, 02:24

pychu
3128
accept rate: 0%

edited 06 Apr '13, 02:25

Part of the problem is with your markup. You have unclosed tags such as in this line: <th>{{ field.label|capfirst }}. This may be causing the output to be rendered incorrectly.

(06 Apr '13, 22:33) waynek
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×900
×30
×20
×9

question asked: 06 Apr '13, 02:24

question was seen: 2,061 times

last updated: 06 Apr '13, 22:33

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM