Django Bootstrap Base Template

Simple django bootstrap base template. Official reference for django template and bootstrap.

Step 1: Preparation, Create Django Project, Initial Migration
install virtualenv: pip install virtualenv
create virtualenv: virtualenv venv
start virtualenv: venv/Scripts/activate
install Django in virtualenv: pip install django==3.0
Create Django: django-admin startproject myproject
Go to myproject folder: cd myproject
Migrate: python manage.py migrate

Step 2. Create Django Apps
Create apps: python manage.py startapp myapp
Add myapp to INSTALLED_APPS in myproject/settings.py

Step 3. Preparing Templates Folder
Add folder templates in myapp

Register myapp/templates in myproject/settings.py

Step 4. Add html file in myapp/templates folder
Add bootstrap base, create base.html CDN Bootstrap.

myapp/template/base.html

Create home.html in myapp/templates which implement base.html. Following codes is jumbotron example from official Bootstrap doc.

myapp/template/home.html

Step 5. Set up views and urls
Add render method in myapp/views.py

myapp/views.py

Create urls.py file in myapp folder

myapp/urls.py

Add myapp/urls.py to myproject/urls.py using include

myproject/urls.py

Step 6. Run and Try it in browser
python manage.py runserver

http://127.0.0.1:8000

Software Engineer