简体   繁体   中英

STATICFILES on Django 1.6.2

This is my settings.py

STATIC_URL = '/static/'

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'),
)

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

My structure is:

manage.py
myproject
-- __init__.py
-- settings.py
-- urls.py
-- wsgi.py
-- static
----- css
----- img
-------- logo.png
----- scripts

I use the static tag in my html file like this: <img src="{{ STATIC_URL }}img/logo.png">

But, it is:

[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (logo.png, line 0)

I really can't understand this issue on Django 1.6.2 version.

Could someone help me to solve this issue?

Thanks in advance!

You need to make sure that the django.contrib.staticfiles app is listed in INSTALLED_APPS :

INSTALLED_APPS = (
    ...
    'django.contrib.staticfiles'
    ...
)

Lastly, you need to make sure that DEBUG is set to True in settings.py .

EDIT:

Try removing 'django.contrib.staticfiles.finders.DefaultStorageFinder' from STATICFILES_FINDERS . Then run $ python manage.py findstatic img/logo.png

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM