Django comments app - adding each field of comments app to div classes

35 views
Skip to first unread message

Code

unread,
Nov 20, 2014, 10:40:40 PM11/20/14
to django...@googlegroups.com
I am using django comments app and am using bootstrap template for UI. 

In bootstrap I have; 

    <div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12">
     
<label class="sr-only" for="inputName">Name</label>
     
<input class="form-control" id="inputName" name="author" type="text" value="" aria-required="true" placeholder="Your Name">
   
</div>


and other div classes to fill in mame , email, url and comments.


Django comments app's 

    {% get_comment_form for post as form %}


allows manually render fields like;

    {{form.user_name}}
   
{{form.user_email}}
    etc
.


Question: How do I integrate `{{form.user_name}}` and other fields in the div class?

Thanks for your help.

Code

unread,
Nov 20, 2014, 11:44:12 PM11/20/14
to django...@googlegroups.com
Also, is there a better alternative to comments app? thanks

Collin Anderson

unread,
Nov 21, 2014, 5:58:18 PM11/21/14
to django...@googlegroups.com
Hi,

The simple way:
<div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12">

  {{ form }}
</div>

The more full way:
<div class="form-group col-lg-4 col-md-4 col-sm-4 col-xs-12">

     
<label class="sr-only" for="id_user_name">Name</label>
     
<input class="form-control" id="id_user_name" name="user_name" type="text" value="{{ form.user_name.value }}" aria-required="true" placeholder="Your Name">
     {{ form.user_name.errors }}
     
<label class="sr-only" for="id_user_email">Email</label>
     
<input class="form-control" id="id_user_email" name="user_email" type="text" value="{{ form.user_email.value }}" aria-required="true" placeholder="Your Email">
     {{ form.user_email.errors }}
</div>

Disqus is a good javascript-based comment system that Django also recommends.

Collin
Reply all
Reply to author
Forward
0 new messages