django静态资源收集

local_settings.py

import os
from pathlib import Path
DEBUG = False
ALLOWED_HOSTS = ['*']
BASE_BASE_DIR = Path(__file__).resolve().parent.parent.parent
# 在项目同级目录allstatic收集静态资源
STATIC_ROOT = os.path.join(BASE_BASE_DIR, "allstatic")

settings.py

try:
    from .local_settings import *
except Exception as e:
    print(e)

执行命令

python3 manage.py collectstatic

静态资源有变动就要执行

posted @ 2022-09-25 19:38  Sherwin_szw  阅读(88)  评论(0编辑  收藏  举报