django生产环境配置static

1.首先setttings.py里面设置STATIC_ROOT = os.path.join(BASE_DIR,'collectstatic')

2.执行python manage.py collectstatic收集静态文件

3.在urls.py里面添加路由映射url(r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_ROOT}),

4.有权限的修改权限

5.settings.py里面的  DEBUG=False,||ALLOWED_HOSTS = ["*"]

6.python mange.py runserver 即可

posted @ 2020-04-10 09:32  烧刘病  阅读(420)  评论(0编辑  收藏  举报
回到页首