我一直在关注django-oauth-plus wiki中的教程,事情进展顺利,直到我点击请求用户授权部分。
嗯,事情进展顺利 - 所有Client .get(...)调用由于某种原因必须使用 follow = True 进行参数化。这有效,直到这一行:
response = c.get("/oauth/authorize/", parameters)
如果没有follow = True,则响应为301(不是预期的200),如果没有,则会产生以下错误:
>>> response = c.get("/oauth/authorize/", parameters, follow=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 447, in get
response = self._handle_redirects(response, **extra)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 567, in _handle_redirects
response = self.get(path, QueryDict(query), follow=False, **extra)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 445, in get
response = super(Client, self).get(path, data=data, **extra)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 229, in get
return self.request(**r)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django_oauth_plus-2.0-py2.6.egg/oauth_provider/views.py", line 94, in user_authorization
authorize_view = get_callable(authorize_view_str)
File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 124, in wrapper
result = func(*args)
File "/usr/local/lib/python2.6/dist-packages/django/core/urlresolvers.py", line 91, in get_callable
lookup_view = getattr(import_module(mod_name), func_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named views
我的Python / Django-fu并不那么强大,我花了最近几天试图解决这个问题。有什么想法吗?
谢谢!