【发布时间】:2014-09-01 07:10:55
【问题描述】:
我有一个需要 ApiKey 身份验证的 api。如果我在本地使用 manage.py runserver 运行这个 api,它工作得很好,但是如果我在本地使用工头启动并部署到 heroku,它会给出以下错误
{
"error_message": "'NoneType' object has no attribute 'DoesNotExist'",
"traceback": "Traceback (most recent call last):\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 195, in wrapper\n response = callback(request, *args, **kwargs)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 435, in dispatch_detail\n return self.dispatch('detail', request, **kwargs)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 453, in dispatch\n self.is_authenticated(request)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/resources.py\", line 536, in is_authenticated\n auth_result = self._meta.authentication.is_authenticated(request)\n\n File \"/Users/carlosbalderas/.virtualenvs/recommenu/lib/python2.7/site-packages/tastypie/authentication.py\", line 197, in is_authenticated\n except (User.DoesNotExist, User.MultipleObjectsReturned):\n\nAttributeError: 'NoneType' object has no attribute 'DoesNotExist'\n"
我正在使用这些 curl 与我的 api 交互 (运行服务器)
curl -H "Authorization: ApiKey USERNAME:APIKEY" http://127.0.0.1:8000/api/v1/user/
(工头)
curl -H "Authorization: ApiKey USERNAME:APIKEY" http://0.0.0.0:5000/api/v1/user/
(heroku)
curl -H "Authorization: ApiKey USERNAME:APIKEY" http://fancy-name.herokuapp.com/api/v1/user/
提前感谢您的帮助!
【问题讨论】:
-
在 shell 中签入时,用户就在那里。每种情况都使用相同的数据库。
-
嗨 Carlos Balderas,您找到解决方案了吗?我也有同样的问题。它在机器 A 上工作,但在机器 B 上使用相同版本的 django、python 和 sweetpie 失败
-
我没有,我已经切换到 Django Rest Framework
标签: django api curl heroku tastypie