HomeОбразованиеRelated VideosMore From: Max Goodridge

How to Apply Bootstrap CSS to a Django Form (Django Tutorial) | Part 50

132 ratings | 14082 views
Enjoyed my video? Leave a like! GitHub Link: https://github.com/maxg203 Personal Website: http://maxgoodridge.com
Html code for embedding videos on your blog
Text Comments (12)
rundown thomas (1 month ago)
is form-control not a bootstrap thing....i thought this was going to be improving a form without a third party framework. these django forms are useless really...i wanted to go without boostrap ...but i cant handle the entire sign in form errors..without bootstrap..djangos version looke horrendous
Saba Siddiqi (1 month ago)
Thank you ! your tutorial really helped !!
Nilso Viani (8 months ago)
Thanks so much! You have a new subscriber! That was so helpful for me!
Johannes Hoppe (8 months ago)
Cool tutorial but since Django 1.11, I would recommend override the templates rather than passing custom attrs. This will have the benefit that all your forms will change. Not the this will leave the admin as is, since it uses it's own widgets and templates.
de4d (9 months ago)
This is probably a stupid question, but do I need Bootstrap to be installed on my computer for this to work?
Maricarmen L. (9 months ago)
He explains that in one of the previous tutorials, I think the 3rd one. You just need to go to https://getbootstrap.com/docs/4.0/getting-started/introduction/ then just copy the CSS link to the head of your html template.
terrysky83 (10 months ago)
Your tutorial helped me achieve what I couldn't do after hours of searching. Thank you so much indeed.
The Dardans (1 year ago)
There is an easier way I think.. instead of templating the form into html via {{ form.as_p }} or any other way .. you'd do this .. {% for el in forms %} <label class="Whateverclass">{{ el.label_tag }}</label> <div class="whateverdiv"> {{ el }} </div> el.label_tag is the label of the forms like.. "post".. and just el is the actual input etc. {% endfor %}
korwin (1 year ago)
There is even easier way to add class to django widgets: if you are using virtualenv just add class="form-control" to your django files: env/lib/python3.5/site-packages/django/forms/templates/django/forms/widgets/input.html env/lib/python3.5/site-packages/django/forms/templates/django/forms/widgets/textarea.html Then each form field rendered with TextInput() widget will have class="form-control" :) And you don't have to add attr everytime you are creating a form field :)
Karishma Agrawal (9 months ago)
Sorry sir, doesn't work. Are any additional setup steps required for this to work?
Jagadish .A (1 year ago)
great thanks to you dude.this is what i have been searching since yesterday.finally here it's
Ankoor Bhagat (1 year ago)
Here is the code up to the end of Part 50: https://github.com/ankoorb/Django-Practice/tree/master/tutorial-50

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.