当我使用多个设置模块时,Django会引发Template DoesNotExist

2024-05-20 01:07:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用多个设置模块,一个用于生产,一个基本和一个本地,不会进入版本控制(在我的例子中是git)。Django提出了TemplateDoesExist,模板就在那里。我的所有设置文件都在里面的“设置”文件夹中。你知道吗

这就是基本.py:http://pastebin.com/Ek4vzyCa

这就是本地.py:http://pastebin.com/S9AAVhH8

这就是生产.py:http://pastebin.com/Zw8bhBfk

以及管理.py:http://pastebin.com/i4AAP1Ce

Internal Server Error: /
Traceback (most recent call last):
File "/home/sebastian/Envs/Spartan/local/lib/python2.7/site-packages      /django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/home/sebastian/Envs/Spartan/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/sebastian/Documents/project-spartan/basicpages/views.py", line 24, in home
'categories': categories
File "/home/sebastian/Envs/Spartan/local/lib/python2.7/site-packages/django/shortcuts.py", line 67, in render
template_name, context, request=request, using=using)
File "/home/sebastian/Envs/Spartan/local/lib/python2.7/site-packages/django/template/loader.py", line 96, in render_to_string
template = get_template(template_name, using=using)

文件“/home/sebastian/Envs/Spartan/local/lib/python2.7/site-packages/django/template/装载机.py“,第43行,在get\u模板中” raise TemplateDoesNotExist(模板名称,chain=chain) TemplateDoesNotExist:基本页面/索引.html [2016年4月28日19:47:48]“GET/HTTP/1.1”500 86041


Tags: djangoinpyhttphomelibpackageslocal
1条回答
网友
1楼 · 发布于 2024-05-20 01:07:21

使用runserver命令中的settings参数,只能将设置用于本地开发:

$ python manage.py runserver  settings=Spartan.local

因此,您只能将生产设置推送到git。你知道吗

相关问题 更多 >