【问题标题】:Django REST API TemplateDoesNotExist ApacheDjango REST API 模板DoesNotExist Apache
【发布时间】:2013-11-05 11:47:00
【问题描述】:

我正在尝试为 Django REST API 框架执行 this tutorial

使用我的 Apache 设置进行测试时,尝试浏览页面时出现此错误:

TemplateDoesNotExist at /
rest_framework/api.html

但是,如果我通过运行python ./manage.py runserver 使用 Python 测试网络服务器进行测试,它可以正常工作。

我需要在 Apache 中进行一些配置更改来解决此问题吗?

提前致谢。

编辑

我注意到它在错误的位置查找文件:

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/usr/local/lib/python2.7/dist-
packages/django/contrib/auth/templates/rest_framework/api.html (File does not exist)

但是我找不到在哪里更改它。

【问题讨论】:

  • 你在使用 virtualenv 吗?
  • 不,我没有使用 virtualenv。那部分我跳过了,因为我在开发盒上。
  • 您好像忘记在您的 INSTALLED_APPS 中添加“rest_framework”了..
  • 不,我肯定添加了它。我在发布之前在谷歌上搜索了错误,其中一个解决方案是 @ptrck 所说的,但它不起作用。

标签: python django apache rest django-rest-framework


【解决方案1】:

我通过创建一个虚拟环境并相应地配置 Apache 解决了这个问题:

WSGIPythonPath /path/to/mysite.com:/path/to/your/venv/lib/python2.X/site-packages

【讨论】:

  • 从上面:看起来您忘记将“rest_framework”添加到您的 INSTALLED_APPS
猜你喜欢
  • 2019-08-06
  • 1970-01-01
  • 2018-12-25
  • 1970-01-01
  • 2017-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-11
相关资源
最近更新 更多