开发者

jpg and css files are missing

开发者 https://www.devze.com 2023-03-15 17:59 出处:网络
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

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.

  1. Did you run ./manage.py collectstatic? Did the process successfully copy your files to 'C:/Users/khalsa/projects/template2/static'?

  2. 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?

  3. 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 sure manage.py runserver does this by default.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号