0

我正在使用 django 1.5.1 和 django social auth 进行社交登录。要获取 facebook 登录 url,我使用这个

from django.template import Template, Context 
facebook_url = Template("{% url 'socialauth_begin' 'facebook' %}").render(Context())

只是得到下面的错误。

Template error:
In template <unknown source>, error at line 1
maximum recursion depth exceeded
1 :  {% url 'socialauth_begin' 'facebook' %} 

它在我的生产服务器和本地开发盒上运行良好,并且 python 和 django 以及 django 社交身份验证版本似乎相同。我试图弄清楚某些库的语法是否发生了变化,其版本在我的测试服务器上可能不同。


追溯:

Request Method: GET
Request URL: <<MYSERVERURL>>

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'djcelery',
 'djcelery_email',
 'social_auth',
 'myapp',
 'postman',
 'storages')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'djangomako.middleware.MakoMiddleware',
 'myapp.myappmiddleware.MYAPPContextMiddleware')


Template error:
In template <unknown source>, error at line 1
   maximum recursion depth exceeded
   1 :  {% url 'socialauth_begin' 'facebook' %} 

Traceback:
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  121.                             response = middleware_method(request, e)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/ec2-user/myapppy/myapp/usercontext.py" in _wrapped_func
  282.                 return func(request, *args, **kwargs)  
File "/home/ec2-user/myapppy/myapp/pageviews.py" in usersignin
  58.         facebook_url = Template("{% url 'socialauth_begin' 'facebook' %}").render(Context())
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/template/base.py" in render
  830.                 bit = self.render_node(node, context)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/template/defaulttags.py" in render
  411.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
  496.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
  382.         possibilities = self.reverse_dict.getlist(lookup_view)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
  297.             self._populate()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
  274.                     for name in pattern.reverse_dict:
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
  297.             self._populate()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
  286.                 lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback
  230.         self._callback = get_callable(self._callback_str)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/utils/functional.py" in wrapper
  29.         result = func(*args)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable
  97.             mod = import_module(mod_name)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
  35.     __import__(name)
File "/home/ec2-user/myapppy/postman/views.py" in <module>
  24. from postman.forms import WriteForm, AnonymousWriteForm, QuickReplyForm, FullReplyForm
File "/home/ec2-user/myapppy/postman/forms.py" in <module>
  28. class BaseWriteForm(GenericForms.ModelForm):
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documents.py" in __new__
  307.         opts = new_class._meta = ModelFormOptions(getattr(new_class, 'Meta', None))
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documents.py" in __init__
  283.             self.document._meta = DocumentMetaWrapper(self.document)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()

<<<REPEATS>>>>>
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  97.                 f.document_type._meta = DocumentMetaWrapper(f.document_type)
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in __init__
  71.         self._setup_document_fields()
File "/home/ec2-user/.virtualenvs/MYAPP/lib/python2.7/site-packages/mongodbforms/documentoptions.py" in _setup_document_fields
  96.             if isinstance(f, ReferenceField) and not isinstance(f.document_type._meta, DocumentMetaWrapper):
File "/home/ec2-user/.virtualenvs/MYAPP/lib64/python2.7/abc.py" in __instancecheck__
  132.         if subclass is not None and subclass in cls._abc_cache:

Exception Type: RuntimeError at /signin
Exception Value: maximum recursion depth exceeded

更新:

似乎 django-postman 模块导致了这个问题。评论出来摆脱了这个问题。仍然不确定为什么它在开发盒和生产服务器上工作而不是在测试服务器上工作。这是一个临时修复,因为将来我将需要 django-postman 模块,但现在我已经解除了自己的封锁。

4

0 回答 0