Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login template issue #19

Closed
lps opened this issue Sep 30, 2011 · 6 comments
Closed

login template issue #19

lps opened this issue Sep 30, 2011 · 6 comments

Comments

@lps
Copy link

lps commented Sep 30, 2011

Hello, can you please help me with this one?

Am I doing something wrong or it is a bug?

TemplateSyntaxError at /accounts/login/

Caught KeyError while rendering: 'request'

Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value:

Caught KeyError while rendering: 'request'

Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/context.py in getitem, line 55
Template error

In template /usr/local/lib/python2.7/dist-packages/django_allauth-0.1.0-py2.7.egg/allauth/templates/socialaccount/snippets/provider_list.html, error at line 4

Caught KeyError while rendering: 'request'

Line 4: "
  • <a title="Google" class="socialaccount_provider google" href="{% openid_login_url openid="https://www.google.com/accounts/o8/id" %}">Google
  • "

    Environment:

    Request Method: GET
    Request URL: http://127.0.0.1:8000/accounts/login/

    Django Version: 1.3.1
    Python Version: 2.7.1
    Installed Applications:
    ['django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'emailconfirmation',
    'uni_form',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.twitter',
    'allauth.openid',
    'allauth.facebook',
    'chat']
    Installed Middleware:
    ('django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware')

    Template error:
    In template /usr/local/lib/python2.7/dist-packages/django_allauth-0.1.0-py2.7.egg/allauth/templates/socialaccount/snippets/provider_list.html, error at line 4
    Caught KeyError while rendering: 'request'
    1 : {% load allauth_tags %}

    2 :

    3 : {% if allauth.openid_enabled %}

    4 :

  • <a title="Google" class="socialaccount_provider google" href=" {% openid_login_url openid="https://www.google.com/accounts/o8/id" %} ">Google
  • 5 : {% endif %}

    6 : {% if allauth.twitter_enabled %}

    7 :

  • Twitter
  • 8 : {% endif %}

    9 : {% if allauth.facebook_enabled %}

    10 :

  • Facebook
  • 11 : {% endif %}

    12 : {% if allauth.openid_enabled %}

    13 :

  • <a title="Yahoo" class="socialaccount_provider yahoo" href="{% openid_login_url openid="http://me.yahoo.com" %}">Yahoo
  • 14 :

  • OpenID
  • Traceback:
    File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

    1.                     response = callback(request, _callback_args, *_callback_kwargs)
      
      File "/usr/local/lib/python2.7/dist-packages/django_allauth-0.1.0-py2.7.egg/allauth/account/views.py" in login
    2. return render_to_response(template_name, RequestContext(request, ctx))
      
      File "/usr/local/lib/python2.7/dist-packages/django/shortcuts/init.py" in render_to_response
    3. return HttpResponse(loader.render_to_string(_args, *_kwargs), **httpresponse_kwargs)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
    4.     return t.render(Context(dictionary))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    5.         return self._render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
    6.     return self.nodelist.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    7.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    8.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
    9.     return compiled_parent._render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
    10.     return self.nodelist.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    11.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    12.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
    13.     return compiled_parent._render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
    14.     return self.nodelist.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    15.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    16.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
    17.         result = block.nodelist.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    18.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    19.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
    20.         return self.nodelist_true.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    21.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    22.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
    23.         return self.nodelist_true.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    24.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    25.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render
    26.     return self.render_template(self.template, context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/loader_tags.py" in render_template
    27.     output = template.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    28.         return self._render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
    29.     return self.nodelist.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    30.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    31.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py" in render
    32.         return self.nodelist_true.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
    33.             bits.append(self.render_node(node, context))
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py" in render_node
    34.         result = node.render(context)
      
      File "/usr/local/lib/python2.7/dist-packages/django_allauth-0.1.0-py2.7.egg/allauth/openid/templatetags/openid_tags.py" in render
    35.         request = context['request']
      
      File "/usr/local/lib/python2.7/dist-packages/django/template/context.py" in getitem
    36.     raise KeyError(key)
      

    Exception Type: TemplateSyntaxError at /accounts/login/
    Exception Value: Caught KeyError while rendering: 'request'

    @lps lps closed this as completed Oct 3, 2011
    @annapowellsmith
    Copy link

    I have the same issue - anyone know the solution?

    @mhoffman
    Copy link

    Hey,

    I found the following hint crucial:

    Requires django.core.context_processors.request in
    TEMPLATE_CONTEXT_PROCESSORS (template syntax errors stating that request is undefined are the symptom)."[1]

    Could this be added to the README.rst? Thanks for this awesome plugin otherwise.

    References:
    [1] http://hackerluddite.wordpress.com/2011/05/17/review-of-4-django-social-auth-apps/

    @michaelfillier
    Copy link

    Thanks Mr. Hoffman. I had disabled the request context processor, enabling it fixed the issue.

    @shacker
    Copy link

    shacker commented Nov 30, 2013

    +1 Please document this, since fresh Django projects do not include that module by default and the error is fairly mysterious.

    @pennersr
    Copy link
    Owner

    This is already documented in the README...

    @shacker
    Copy link

    shacker commented Dec 1, 2013

    Ah, I see now. I interpreted the example wrong - thought it meant "after whatever else you've got in TEMPLATE_CONTEXT_PROCESSORS, add this."

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...
        "django.core.context_processors.request",
        ...
        "allauth.account.context_processors.account",
        "allauth.socialaccount.context_processors.socialaccount",
        ...
    )
    

    Now I see how you've used the ellipses there. Slightly ambiguous, but yes, it's there. Thanks.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants