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

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

186 ratings | 18099 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 (14)
Tabish -Tech and Gaming- (3 months ago)
Love u <3 thanks
Marcelo Enciso (5 months ago)
Thank you bro! I really need to know how to modify!!
rundown thomas (6 months 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 (7 months ago)
Thank you ! your tutorial really helped !!
Nilso Viani (1 year ago)
Thanks so much! You have a new subscriber! That was so helpful for me!
Johannes Hoppe (1 year 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 (1 year ago)
This is probably a stupid question, but do I need Bootstrap to be installed on my computer for this to work?
Maricarmen L. (1 year 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 (1 year 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 (1 year ago)
Sorry sir, doesn't work. Are any additional setup steps required for this to work?
Jagadish .A (2 years ago)
great thanks to you dude.this is what i have been searching since yesterday.finally here it's
Ankoor Bhagat (2 years 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.