1

I have a Django form, which has a lot of fields so that I have to break it up to 3 pages. It means user has to fill some fields of the form in one page , and then they click next to go to next pages and continue to fill the forms.

To achieve that, I plan to display some fields of the form on each page.

I have come up with this code:

HTML Page 1:

 <form method="POST" action="#" class="form">
     {{form.email}}
     {{form.phone_number}} ...
</form>

HTML Page 2 :

<form method="POST" action="#" class="form">
    {{form.current_job}}
    {{form.current_salary}}...
</form>

It works fine with this code but it just shows the form in basic appearance, I would like to use bootstrap to make it more beautiful.

My questions is that, how can I integrate bootstrap ?

I have come up with this solution, but it is hard-coded and difficult if I changes fields of the form in the future:

<label class="control-label" for="id_field1">Field 1</label>
    <input class="form-control" id="id_field1" maxlength="50" name="field1"  type="text"/>

<label class="control-label" for="id_field2">Field 2</label>
        <input class="form-control" id="id_field2" maxlength="50" name="field2"  type="text"/>

Thank you for your help!

Huy Than
  • 1,538
  • 2
  • 16
  • 31
  • Possible duplicate of [Paginating the results of a Django forms POST request](http://stackoverflow.com/questions/2266554/paginating-the-results-of-a-django-forms-post-request) – Tony Aug 03 '16 at 00:00
  • Thank you for your suggestion, I have read that but found no answer for my question. My question is about how to display only some fields in the form in HTML with the decoration of bootstrap. – Huy Than Aug 03 '16 at 16:53
  • Thanks for clarifying, I've retracted my close vote. – Tony Aug 03 '16 at 17:01
  • this answer might be useful: http://stackoverflow.com/questions/401025/define-css-class-in-django-forms#answer-20573612 Just add the bootstrap classes you need to your fields – Brian H. Aug 04 '16 at 07:57

0 Answers0