1.下载bootstrap源码,放在static目录中
https://v5.bootcss.com/docs/getting-started/download/


https://getbootstrap.net/docs/getting-started/introduction/

Django引入Boostrap 导航栏_django

2.导入样式 js和css格式不同❗
<script src="/static/bootstrap/js/bootstrap.bundle.js"></script>

<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">


3.找到setting.py修改STATIC_URL
STATIC_URL = '/static/'
STATICFILES_DIRS = ( os.path.join('static'), )
STATIC_ROOT = ''


4.setting.py修改TEMPLATES下的'DIRS'
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates")],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

5.找到应用下的view.py文件,修改如下:
#视图函数,返回index.html页面  
from django.http import HttpResponse  
from django.shortcuts import render  
def index(request):  
    return render(request, 'index.html')


6.在跟路由urls.py文件修改如下:
from django.urls import path
from App import views
 
urlpatterns = [
    # 首页
    path('user/', views.index, name="index"),
]