0

My static file setting is

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

and i install ckeditor in my project, and in urls.py :

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

when i get ckeditor.js from http://127.0.0.1:8000/admin/chicinfo/article/add/static/static/ckeditor/ckeditor/ckeditor.js, I can't get this file. Below picture show my problem: enter image description here

What happen to me?

Community
  • 1
  • 1
Jack Zhang
  • 2,534
  • 5
  • 25
  • 34
  • Could you please let us know you template code where you include static content and please update STATIC_URL = 'static/' to STATIC_URL = '/static/' – Shreeyansh Jain Jul 30 '13 at 11:49
  • If any of the below answers resolved your problem, please mark one of them as correct. –  Jul 30 '13 at 12:53
  • @AnshJ I tried to modify that to '/static/ but i found that all css files in admin main page is missing. when i use 'static/', css files in admin is fine. Which one should i choose? – Jack Zhang Jul 31 '13 at 07:00

1 Answers1

0

I suspect you are putting /static/ in the actual url in your templates. E.g,

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

You don't need to put the static bit in if you are using static_url. It should be:

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

You should also put the static files serving URL at the end of your url config.

Working example:

url(r'^static/(?P<path>.*)$',
    'django.views.static.serve',
    {'document_root': settings.STATIC_ROOT, }),
  • I didn't modify the source of ckeditor.js because it's a app. And it will parse url by this application itself. by just add `(r'^ckeditor/', include('ckeditor.urls')),` – Jack Zhang Jul 31 '13 at 07:01