DEV Community

Cover image for Install and use Bootstrap5 in Django
Schleidens.dev
Schleidens.dev

Posted on

Install and use Bootstrap5 in Django

You can use the latest version of bootstrap (bootstrap5) in django by install the module in your virtual environment.

There's other ways you can achieve that too -> include CDN, download the required files in include them in your project. But my favorite one is install the module.

Letsgooo.

inside your project active the virtual environment source myEnv/bin/activate if you're using venv as your virtual environment.
:: replace myEnv* by your virtual environment name

Once you are inside the virtual environment, install Bootstrap 5 with this command:
pip install django-bootstrap-v5

you should get something like this
result from 'pip install django-bootstrap-v5' command

inside your terminal type
pip freeze > requirements.txt

result from freeze

update your settings.py and add bootstrap to your apps

add it to you apps list

now add bootstrap style to your master template
What is a master template ?

add these 3 lines in your html head

{% load bootstrap5 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
Enter fullscreen mode Exit fullscreen mode

how it looks in your HTMl

Bravo, you've been added Bootstrap5 in your project.

let's connect on X/Twitter for more engagement

Top comments (0)