开发者

How to serve static files in production for Django 1.3

开发者 https://www.devze.com 2023-03-24 11:31 出处:网络
I\'m deploying my app and I wonder what I\'m missing. I did the following: Set my STATIC_ROOT to an empty folder in my server.

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


. 4. Point Apache at your static folder.


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.

0

精彩评论

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

关注公众号