我正在接手一项使用Django的产品,但我完全不知道如何使用它。
我的目标是在我的base.html
文件中提供不同的scripts
,类似于以下内容:
<!-- if development -->
<script src="{% static "js/main.js" %}></script>
<! -- end -->
<!-- if production -->
<script src="{% static "production/js/main.min.js" %}></script>
<! -- end -->
文件结构如下:
app_name
|__ pages
|__ settings
|__ static
|__ templates
|__ etc
在 settings
文件夹内,看起来有三个文件:
base.py : shared settings
development.py
production.py
在 development.py
内部,
from app_name.settings.base import *
DEBUG = True
TEMPLATE_DEBUG = DEBUG
// etc
我曾试图在
templates/base.html
中实现以下类似的操作,但显然并不容易。{% if DEBUG %}
STUFF
{% endif %}
有需要帮助的吗?
context_processors.py
文件保存在哪里? - cusejuice