Some other options:

- Install https://github.com/dyve/django-bootstrap-toolkit and use {{
form|as_bootstrap }}. See the docs for more options.

- http://django-crispy-forms.readthedocs.org/en/latest/ Crispy Forms is
amazing BTW (by the way)

- Render your labels with {{form.field_name.label}} and fields with
{{form.field_name}} and errors with {{form.field_name.errors}} inside that
boostrap markup. You'll have to do this individually for every field
though. As for the attributes, such as placeholder, classes and data
attributes, you have to pass the to the widget class inside attr={}

Cheers,

M





On 19 August 2014 20:15, Martin Spasov <suburb4nfi...@gmail.com> wrote:

> Maybe you could copy the classes and id's from the template and put them
> in your form like this :
>
> class  SomeForm(forms.Form):
>     name=forms.CharField(attrs={'class':'form-control', 'id':'name'})
>     message=forms.CharField(widget=forms.TextInput(attrs={'class':'the
> class name thats on the templates form for the text input'})
>
> And then pass the SomeForm to the view as some context variable, for
> example 'form'.
> In your template :
>                              <form name="sentMessage" id="contactForm"
> novalidate>
>                                 <div class="form-group">
>                                    {%for field in form%}
>                                        {{field.label}} {{field}}
>                                    {%endfor%}
>                                 <button type="submit" class="btn
> btn-xl">Send Message</button>
>                              </form>
>
> This is just advice from beginner to beginner and if there is an easier
> way please correct me! If you choose this way Kim and you don't understand
> something please ask!
>
> On Tuesday, August 19, 2014 9:36:55 AM UTC+2, Kim wrote:
>>
>> Thank you for the advice, Collin!
>> However, If I have this HTML below, where should I put {{ form.[name] }}?
>>
>>                              <form name="sentMessage" id="contactForm"
>> novalidate>
>>                                 <div class="form-group">
>>                                     <input type="text"
>> class="form-control" placeholder="Your Name *" id="name" required
>> data-validation-required-message="Please enter your name.">
>>                                     <p class="help-block text-danger"></p>
>>                                 </div>
>>                                 <button type="submit" class="btn
>> btn-xl">Send Message</button>
>>                              </form>
>>
>> 2014年8月19日火曜日 10時42分19秒 UTC+9 Collin Anderson:
>>>
>>> I recommend making the same contact form in django first, then merge the
>>> two. Your starter template only makes the form look good, it doesn't
>>> provide much functionality.
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c25c646e-bbc2-44c5-a4d4-fe36296c9b88%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c25c646e-bbc2-44c5-a4d4-fe36296c9b88%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbjkgxCVe5buPNj-e0h4okhNkvFO6DZbcW_pRiOC1DXW9Uw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to