gpt4 book ai didi

Django 1.4 : static file not found

转载 作者:行者123 更新时间:2023-12-01 15:27:08 25 4
gpt4 key购买 nike

我尝试用谷歌搜索,但无法解决我的问题。很多人都有这个问题,并尝试按照他们的指示进行操作,但我仍然无法解决。那么,我的配置有什么问题吗?

--- 设置.py ----

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
STATIC_URL = '/static/'

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages")

---views.py---

render_to_response('authen/login.html',context_instance=RequestContext(request))

---登录.html---

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}styles/reset.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}styles/root.css" />

---错误---

[16/Apr/2012 21:27:26] "GET /authen/login.php HTTP/1.1" 200 1391
[16/Apr/2012 21:27:26] "GET /static/styles/reset.css HTTP/1.1" 404 1652
[16/Apr/2012 21:27:26] "GET /static/styles/root.css HTTP/1.1" 404 1649

---urls.py---

if settings.DEBUG:
urlpatterns += patterns('django.contrib.staticfiles.views',
url(r'^static/(?P<path>.*)$', 'serve'),
)

最佳答案

您可能正在寻找:

https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#static-file-development-view

更新:我看到您有静态文件的 url 模式。你在 settings.py 中有 DEBUG=True 吗?

关于 Django 1.4 : static file not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10180508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com