简体   繁体   中英

How to serve static files in production for Django 1.3

I'm deploying my app and I wonder what I'm missing.

I did the following:

  1. Set my STATIC_ROOT to an empty folder in my server.
  2. Set the STATIC_URL to '/static/'
  3. Added 'django.contrib.staticfiles' to INSTALLED_APPS

In development my static files are in the root of my app in a folder named static.

So, I ran manage.py collectstatic and all my files were copied to my static_root.

However, it doesn't work. I don't know if i'm missing any step.

Any help would be great Thanks

As explained in Django's documentation , Django serves static files itself in development only, when deploying your application in production, it's up to you to make your web server (apache, lighttpd, nginx, whatever) serve the static files.

Django's documentation provides instructions for doing so with Apache here

Django while it's not in debug mode should not serve static files, for performances reasons, you should use:

./manage.py collectstatic

then configure your web server (apache or nginx) to serve this folder to the right url.

. 4. Point Apache at your static folder.

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