Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Even if I followed the official instructions, when I start a Django test site using uWSGI, CSS files for the admin interface are not loaded. If I open the URL of a CSS file, for example http://localhost:8443/static/admin/css/base.css, I get a 404 error. I searched for the local file and I guess its path is /usr/local/lib/python3.3/dist-packages/django/contrib/admin/static/admin/css/base.css; so I also tried to run uwsgi as root, but nothing changed.

I have no problem using python3 manage.py runserver. If I open http://localhost:8000/static/admin/css/base.css, the file is loaded in the browser, and the style is applied to the admin page.

This is the command I execute in bash:

uwsgi --ini ~/.uwsgi/conf/django.ini --set-placeholder project_name=mysite --set-placeholder port=8443

and this is the content of django.ini:

[uwsgi]
module = %(project_name).wsgi:application
https = :%(port),/usr/local/nginx/conf/server.crt,/usr/local/nginx/conf/server.key,HIGH
strict = true
chdir = /home/marco/django-projects/%(project_name)
env = DJANGO_SETTINGS_MODULE=%(project_name).settings
socket = /home/marco/.uwsgi/%(project_name).socket
pidfile = /home/marco/.uwsgi/%(project_name).pid
daemonize = /home/marco/.uwsgi/%(project_name).log
master = true
enable-threads = true
harakiri = 20
max-requests = 5000
vacuum = true
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Official deployment docs (independently by the WSGI server) do not cover serving static files (that is generally managed by the webserver). The right docs are here:

https://docs.djangoproject.com/en/dev/howto/static-files/deployment/

eventually serving static files is pretty easy with uWSGI:

http://uwsgi-docs.readthedocs.org/en/latest/StaticFiles.html

but if you can do it in nginx it is better

share|improve this answer
    
Thank you, I also followed this simple tutorial: uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html , even if it does not remember to add to PROJECT/settings.py the line STATIC_ROOT = os.path.join(BASE_DIR, "static")and run python3 manage.py collectstatic. –  Lucas Malor Dec 14 '13 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.