我正在尝试加载 CSS 文件,但由于某种原因它无法找到该文件。这是我在加载文件时遇到的错误:
---[05/May/2013 11:31:58] "GET /static/css.css HTTP/1.1" 404 1625
File structure
Folder structure
ecomstore
ecomstore
catalog
preview
Templates
Catalog
base.html
static
css.css
网址.py
from django.contrib import admin
import os
admin.autodiscover()
static = os.path.join(os.path.dirname(__file__), 'static')
print 'static=',static
urlpatterns = patterns('',
(r'^catalog/$','ecomstore.preview.views.home'),
url(r'^admin/', include(admin.site.urls)),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root':static}),
(r'^',include('ecomstore.catalog.urls')),
)
base.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "XHTML1-s.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>DJANGO E-Commerce website</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{% block title %}{% if page_title %}{{ page_title }} - {% endif %} ?
{{ site_name }}{% endblock %}</title>
<meta name="keywords" content="{{ meta_keywords }}" />
<meta name="description" content="{{ meta_description }}" />
<link rel="stylesheet" href="/static/css.css"
type="text/css" />
<script src="/static/jquery.js" type="text/javascript"></script>
</head>
<body>
{% block site_wrapper %}{% endblock %}
</body>
</html>
settings.py
STATIC_ROOT = ''
STATIC_URL = '/static/'