Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin static files 404

I'm using Django version 1.10. Project work fine on Debug = True, but when I set it to False is not. Django just can't find static files.

My Django settings looks like:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'master',
'update',
]

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

STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = '/static/'
STATICFILES_DIRS = ()

And the urls.py

from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^master/', include('master.urls')),
    url(r'^update/', include('update.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

uwsgi.ini file

[uwsgi]
chdir           = %v
virtualenv      = %v/py
module          = go_conf.wsgi
master          = true
http            = :8000
vacuum          = true

buffer_size     = 64k
max-requests    = 100
daemonize       = %v/log.txt

I aslo used python manage.py collectstatic, and it collected everything but still not working.

I tried to solve this by reading other articles on this site, but nothing really worked for me.

Hope, that someone will at last help.

like image 236
Mr. Nobody Avatar asked Dec 23 '22 20:12

Mr. Nobody


1 Answers

This is the Django desing. A quote from the docs for Static file development view:

This view will only work if DEBUG is True.

That’s because this view is grossly inefficient and probably insecure. This is only intended for local development, and should never be used in production.

If you are setting DEBUG=False you are probably going to make it production. If so, your static files must be served by a webserver (eg. Nginx, Apache etc).

like image 99
abcdn Avatar answered Dec 29 '22 11:12

abcdn