Install boostrap into your Django Application
1. CONNECT WITH BOOTSTRAP CDN
To connect the Boostrap in your Django app, there is a two way to do it.One is to use Bootstrap CDN you can get it from their official website https://www.bootstrapcdn.com
get the cdn boosttrap css and js file to your html file and you will enable to use their classes by this.
2. CONNECT WITH BOOTSTRAP BY INCLUDE
Another way is little bit tricky but more appropiate to use for projects specially local projects where Internet connection could be an issue.
So to include bootstrap to your Django project.First you need to download the bootstrap file from their main site https://getbootstrap.com
Then create a file in the directory path like "projectname/appname/static"
In the picture my project name is TestProjectC and Application name is coins.so inside the coins folder I create a folder called "static".you can also change the name according to your preference.
Inside the static folder paste the bootstrap files but make sure you extract it before.
Now the main part comes in to connect and show the Django system to use the css and js files from that directory.
In the project there is a file name settings.py just open that file and add STATIC_URL = '/static/' if you don't have that in your settings file
After include the STATIC_URL in the same file include thi lines
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'appname/static/bootstrap'),
)
Now go to your html file where you want to cinclude your boostrap file
inside the head tag just put
<link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
in the same system you can add the js file also the custom css file
To know more about basic stuff follow the blog
Thank you so much.
To connect the Boostrap in your Django app, there is a two way to do it.One is to use Bootstrap CDN you can get it from their official website https://www.bootstrapcdn.com
get the cdn boosttrap css and js file to your html file and you will enable to use their classes by this.
2. CONNECT WITH BOOTSTRAP BY INCLUDE
Another way is little bit tricky but more appropiate to use for projects specially local projects where Internet connection could be an issue.
So to include bootstrap to your Django project.First you need to download the bootstrap file from their main site https://getbootstrap.com
Then create a file in the directory path like "projectname/appname/static"
In the picture my project name is TestProjectC and Application name is coins.so inside the coins folder I create a folder called "static".you can also change the name according to your preference.
Inside the static folder paste the bootstrap files but make sure you extract it before.
Now the main part comes in to connect and show the Django system to use the css and js files from that directory.
In the project there is a file name settings.py just open that file and add STATIC_URL = '/static/' if you don't have that in your settings file
After include the STATIC_URL in the same file include thi lines
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'appname/static/bootstrap'),
)
Now go to your html file where you want to cinclude your boostrap file
inside the head tag just put
<link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
in the same system you can add the js file also the custom css file
To know more about basic stuff follow the blog
Thank you so much.
Comments
Post a Comment