2013-07-30 55 views
0

我的靜態文件設置爲django兩個'靜態'路徑在我的網址?

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

,我安裝在我的項目的CKEditor,並在urls.py:

url(r'static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT,}), 
(r'^ckeditor/', include('ckeditor.urls')), 

當我從http://127.0.0.1:8000/admin/chicinfo/article/add/static/static/ckeditor/ckeditor/ckeditor.js得到ckeditor.js,我不能讓這個文件。 下圖顯示了我的問題: enter image description here

發生了什麼事情?

+0

能否請您讓我們知道你的模板代碼,你包括靜態內容請更新STATIC_URL =「靜態/」到STATIC_URL =「/靜態/」 –

+0

如果有任何的下方答案解決了你的問題,請將其中一個標記爲正確。 – 2013-07-30 12:53:21

+0

@AnshJ我試圖將其修改爲'/靜態/但我發現管理主頁中的所有css文件都丟失了。當我使用'靜態/'時,管理員的css文件很好。 我應該選擇哪一個? –

回答

0

我懷疑你把/靜態/在你的模板中的實際URL。例如,

<scirpt src="{{ STATIC_URL }}static/ckeditor/ckeditor/jkeditor.js" /> 

如果您使用的是static_url,則不需要將靜態位置入。它應該是:

<script src="{{ STATIC_URL }}ckeditor/ckeditor/jkeditor.js" /> 

您還應該將靜態文件提供URL在URL配置的末尾。

工作例如:

url(r'^static/(?P<path>.*)$', 
    'django.views.static.serve', 
    {'document_root': settings.STATIC_ROOT, }), 
+0

我沒有修改ckeditor.js的源代碼,因爲它是一個應用程序。它會通過這個應用程序本身解析url。通過添加'(r'^ ckeditor /',include('ckeditor.urls')),' –