我有我的urls.py行:Django的靜態文件
if settings.DEBUG==True:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT})
)
在我的設置文件是這樣的:
STATIC_DOC_ROOT = os.path.join(os.path.dirname(__file__),'static').replace('\\','/')
當我去/在我的網頁一切工作好了。當我點擊從/到另一個頁面的鏈接時,由於404錯誤,我沒有應用CSS。他試圖從該URL加載CSS文件。
http://localhost:8000/show/sth/static/style.css
這裏是我的這種方法
(r'^show/(?P<subject>[^/]+)/(?P<title>[^/]+)$','show'),
我的網址/鏈接和CSS的工作只是在這一個模板,這是行不通的urls.py。看來這些參數搞亂了一些東西。任何建議爲什麼這會失敗? 這裏是我的模板代碼:
{% extends "szkielet.html" %}
{% block tresc %}
<div id="content">
<div class="post">
<h2 class="title">{{ notatka.tytul }}</h2>
<p class="meta"><span class="author">{{ notatka.user.name }}</span> <span class="date">July 07, 2010</span> <span class="links"><a href="#" title="">Comments</a></span></p>
<div class="entry">
<p>{{ notatka.tresc }}</p>
</div>
</div>
</div>
{% endblock %}
Szkielet.html - 這是我的基地
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Perfect Blemish by Free CSS Templates</title>
<link href="{{ MEDIA_URL }}style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
這裏是負責CSS部分它只有一個樣式表。
我想你有一個基本的HTML來擴展所有的模板。你忘了在這個頁面上擴展嗎? – 2011-03-06 15:37:34
我有擴展部分。問題在於,在一個模板中,由於路徑不正確,路徑不正確,因此css無法正常工作。 – John 2011-03-06 16:46:42