How to set tailwind-css or bootstrp and js file in django for offline work?

69 Views Asked by At

In django, is there any way to link-up bootstrap css and js file to work in offline? I find solution for link-up tailwind-css with my django project also.

I create a static folder globally. I keep these files in static folder. Then I try to link-up these files by using and tags from base.html file which is located in templates folder. I also set dirs = ['templates'] in my settings.py file. But they don't work.

1

There are 1 best solutions below

0
Abu RayhaN On

1.Visit the official Bootstrap website and download the Bootstrap ZIP file. Extract the contents of the ZIP file to get the Bootstrap CSS and JS files.

2.Inside the "static" folder, create subdirectories for "css" and "js".

3.Copy the Bootstrap CSS file (bootstrap.min.css) to the "css" folder and the Bootstrap JS file (bootstrap.min.js) to the "js" folder. 4. set this in settings.py

STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

in you main html file which you're using as a template write

{% load static %}

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
</head>
<body>
    <!-- Your content here -->

    <script src="{% static 'js/bootstrap.min.js' %}"></script>
</body>
</html>

use the load static template tag in you html files. if this does not solves the problem go to google and write "how to use bootstrap with with django offline"