Why use Django's collectstatic instead of just serving the files directly from your static directory?

前端 未结 2 2090
天命终不由人
天命终不由人 2021-02-12 16:39

From the Django Docs:

Deployment django.contrib.staticfiles provides a convenience management command for gathering static files in a single directory s

2条回答
  •  情深已故
    2021-02-12 17:09

    Why not just serve your static directory? You might use more than one app, and some of your apps may not be under your control. Before the staticfiles app existed, you then had to either manually copy the static files for all apps to a common directory, upload them to your CDN, or symlink them to the document root of your web server.

    The staticfiles app established a convention: put static files for each app under a static directory and let Django do the work for you.

提交回复
热议问题