在Django中将相同的静态文件用于多个应用程序 [英] Use the same static file into multiple apps in Django

查看:52
本文介绍了在Django中将相同的静态文件用于多个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Django项目分为多个应用程序,静态文件按如下方式存储在每个应用程序中:

My Django project is divided into several apps, and the static files are stored in each app like this:

/Project
   /foo
      /static
         /css
            /style.css
      /views.py
      /models.py
      /urls.py
   /bar
      /static
         /css
            /style.css
      /views.py
      /models.py
      /urls.py
   /urls.py
   /manage.py
   /settings.py

但是我不确定如何将相同的静态文件用于多个应用程序.

But I am not sure how to use the same static files into multiple apps.

推荐答案

这是

This is what the STATICFILES_DIRS setting is for:

您的项目可能还会有与之无关的静态资产特定的应用程序.STATICFILES_DIRS设置是的元组加载静态文件时要检查的文件系统目录.它是搜索路径默认为空.

Your project will probably also have static assets that aren’t tied to a particular app. The STATICFILES_DIRS setting is a tuple of filesystem directories to check when loading static files. It’s a search path that is by default empty.

这篇关于在Django中将相同的静态文件用于多个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆