jpg and css files are missing
I'm new to django. so I need your help. I am having a problem, my css and jpg开发者_Go百科s are missing. I read this tutorial Managing static files. But found no luck. Can any one help me?? thanks
setting.py
STATIC_ROOT = 'C:/Users/khalsa/projects/template2/static'
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.staticfiles',
)
URL setting
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
Image Path
<img src="{{ STATIC_URL }}images/11.jpg" alt="image" />
There are a few things to check.
Did you run
./manage.py collectstatic
? Did the process successfully copy your files to 'C:/Users/khalsa/projects/template2/static'?Localhost issues: Is Django is using 'http://127.0.0.1/static/' and you are using 'http://localhost/static/' in your browser, or vice-versa?
Finally, you will need to determine if
runserver
serves the static files. The documentation says "Deploy those files by configuring your webserver of choice to serve the files in STATIC_ROOT at STATIC_URL." I am not suremanage.py runserver
does this by default.
精彩评论