Django管理模板覆盖在生产环境中不起作用 [英] Django admin template overrides not working in production environment
问题描述
像此问题,我的管理员覆盖在我的生产环境,但它们在我的开发环境(相同的django版本)。我已经尝试在settings.py中重新排序INSTALLED_APPS元组,而不改变(上面链接的问题的答案)。以下是我的项目构建方式:
Like this question, my admin overrides aren't working in my production environment but they are in my development environment (same django version). I've tried reordering the INSTALLED_APPS tuple in settings.py with no change (was the answer to the question linked above). Here's how I have my project constructed:
/WebDJ/ # project dir
+devices # unrelated app, but it uses templates (see below)
+sales
__init__.py
admin.py
models.py # has Customer and Transaction model classes
+templates
+admin
+sales
+Customer
change_form.html
+Transaction
change_form.html
+devices # lots of templates under here that work fine
404.html
500.html
还:
TEMPLATE_DIRS = ('/WebDJ/templates',)
在settings.py中设置。设备应用中的模板很好。没有加载什么是管理目录中的覆盖 - 所以客户和事务的更改表单添加了一些额外的东西(覆盖after_field_sets块)。
is set in settings.py. The templates in the devices app are fine. What's not loading are the overrides in the admin directory - so the change form for Customer and Transaction has some extra stuff added to them (overriding the "after_field_sets" block).
再次,它在我的开发环境(使用PyCharm)中工作,但不在我的生产环境中。有任何想法吗?
Again, it works in my development environment (using PyCharm) but not in my production environment. Any ideas? I'm really stumped on this one.
推荐答案
答:在我的生产机器上,显然不喜欢客户和交易,尽管它是模型的确切名称 - 它需要客户和交易。
Answer: on my production machine, apparently it didn't like "Customer" and "Transaction" despite that being the exact name of the models - it needed "customer" and "transaction".
这篇关于Django管理模板覆盖在生产环境中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!