python django 访问静态文件出现404或500错误
更新时间:2017年01月20日 08:34:24 投稿:lqh
这篇文章主要介绍了python django 访问静态文件出现404或500错误的相关资料,需要的朋友可以参考下
django static文件夹下面的内容方法不了 出现404 500错误
需要查看自己的settings文件确保有一下内容
import os PROJECT_ROOT = os.path.dirname(__file__) DEBUG = True STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', )
如果项目是使用eclipse启动的django工程 settings文件中的DEBUG 值要等于True 静态文件才能访问?这一点不太明白
如果需要部署到web站点上需要在apache中配置静态文件映射
<VirtualHost *:80> ServerName www.mydjangosite.com ServerAlias mydjangosite.com ServerAdmin fake@mydjangosite.com DocumentRoot /path/to/mydjangosite <Directory /path/to/mydjangosite> Options FollowSymLinks AllowOverride None Order allow,deny allow from all </Directory> Alias /static/ /path/to/mydjangosite/static/ <Directory /path/to/mydjangosite/static> Order allow,deny allow from all </Directory> # The following installs the Django WSGI app WSGIDaemonProcess www.mydjangosite.com processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup www.mydjangosite.com WSGIScriptAlias / /path/to/mydjangosite/wsgi.py </VirtualHost>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关文章
Python数据可视化教程之Matplotlib实现各种图表实例
这篇文章主要给大家介绍了关于Python数据可视化教程之利用Matplotlib实现各种图表的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起看看吧2019-01-01Python函数中apply、map、applymap的区别
这篇文章主要介绍了 Python函数中apply、map、applymap的区别 ,文章围绕 Python函数中apply、map、applymap的相关资料展开详细内容,需要的朋友可以参考一下2021-11-11Python Excel操作从零学习掌握openpyxl用法
这篇文章主要为大家介绍了Python Excel操作从零学习掌握openpyxl用法示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-08-08
最新评论