我需要將一個CSS文件鏈接到一個簡單的hmtl頁面,但它不起作用!我有紅色的文檔,並觀看了Linux系統上開發的10個視頻,但其中沒有一個與Windows的配置一起出現!如何在Windows上使用Django 1.4來服務靜態文件?
由於某種原因我使用的版本以這種方式創建樹! (如果沒猜錯糾正我,因爲我真的很新的Django)
mysite
\blog
\static
style.css
\templates
index.html
__init__.py
models.py
tests.py
views.py
\mysite
url.py
settings.py
wsgi.py
manage.py
我加入了網址settings.py
文件:
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
('assets','blog/static'),
views.py
看起來是這樣的:
from django.http import HttpResponse,Http404,HttpRequest
from django.shortcuts import render_to_response
def change_form(request):
return render_to_response('index.html')
然後我做了Collectstatic命令,並且名稱下的Dir(資產)被添加到mysite 的根目錄中,我的index.html看起來像這樣
{& load static &}
<!DOCTYPE html>
<html>
<head>
<!--Meta tags-->
<meta charset="utf-8">
<!--Title-->
<title>Menu Notification Badges</title>
<!--Stylesheets-->
<link rel="stylesheet" href="{% static 'assets/css/styles.css' %}">
</head>
,我現在收到此錯誤:
TemplateSyntaxError at /change-form/
Invalid block tag: 'static'
Request Method: GET
Request URL: http://localhost:8000/change-form/
Django Version: 1.4.5
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag: 'static'
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in invalid_block_tag, line 321
Python Executable: C:\Python27\python.exe
Python Version: 2.7.3
Python Path:
['E:\\DjangoSites\\mysite',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
Server time: Sat, 27 Apr 2013 09:57:21 +0300
Error during template rendering
In template E:\DjangoSites\mysite\blog\templates\index.html, error at line 13
Invalid block tag: 'static'
3 <html>
4 <head>
5
6 <!--Meta tags-->
7 <meta charset="utf-8">
8
9 <!--Title-->
10 <title>Menu Notification Badges</title>
11
12 <!--Stylesheets-->
13 <link rel="stylesheet" href="{% static 'assets/styles.css' %}">
請不要將我的文檔!而不是LINUX文件系統的解決方案!
這是kindda的事情,讓我懷疑爲什麼我選擇了WebDev!
MAAAN!我欠你跟我的學位!這是我的畢業頂層!我是如此接近拔頭髮出來的我頭! Ima gine我已經制作了一個文本引擎,但是這阻止了我設計這些頁面! – 0bserver07 2013-04-27 08:18:13