【发布时间】:2016-01-20 22:48:16
【问题描述】:
我试图将我的模板放在一个单独的文件中,并使用 Django loader.get_template('temaplte name') 加载它。现在这应该可以了,但是在处理未加载的应用程序时出现错误。关于如何解决它的任何想法?我也在 windows 上的 eclipse 中使用 python 3.2。
加载器来源:http://www.djangobook.com/en/2.0/chapter09.html
from django.template import Template, Context, loader
from django.conf import settings
settings.configure()
t=loader.get_template('template.html')
c=Context({"Name":"Adrian"})
print(t.render(c))
错误信息
File "C:\Users\212412120\Downloads\Django-1.7\Django-
1.7\django\apps\registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
【问题讨论】:
-
你有什么解决办法吗??我也面临同样的问题。
标签: python-3.x django-templates