vgarvardt / django-loginza

Django application for Loginza service
http://loginza.ru
38 stars 17 forks source link

TemplateSyntaxError #4

Closed xAlexo closed 13 years ago

xAlexo commented 13 years ago

TemplateSyntaxError at /

Caught KeyError while rendering: 'request'

Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.3 Exception Type: TemplateSyntaxError Exception Value:

Caught KeyError while rendering: 'request'

Exception Location: C:\Program Files\Python2\lib\site-packages\django\template\context.py in getitem, line 60 Python Executable: C:\Program Files\Python2\python.exe Python Version: 2.7.1

Template error

In template *, error at line 61 Caught KeyError while rendering: 'request' 57 {% load loginza_widget %} 58 {% if user.is_authenticated %} 59 Добро пожаловать, {{ user }} 60 {% else %} 61 {% loginza_button "Войти через loginza" %} 62 {% endif %}

vgarvardt commented 13 years ago

Can you provide full stack trace?

xAlexo commented 13 years ago

Traceback: File "C:\Program Files\Python2\lib\site-packages\django\core\handlers\base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "D:\Users\Alexo\PycharmProjects\dev_wcobs_com\news\views.py" in home
  2. return render_to_response('base.html') File "C:\Program Files\Python2\lib\site-packages\django\shortcutsinit.py" in render_to_response
  3. return HttpResponse(loader.render_to_string(_args, *_kwargs), **httpresponse_kwargs) File "C:\Program Files\Python2\lib\site-packages\django\template\loader.py" in render_to_string
  4. return t.render(Context(dictionary)) File "C:\Program Files\Python2\lib\site-packages\django\template\base.py" in render
  5. return self._render(context) File "C:\Program Files\Python2\lib\site-packages\django\template\base.py" in _render
  6. return self.nodelist.render(context) File "C:\Program Files\Python2\lib\site-packages\django\template\base.py" in render
  7. bits.append(self.render_node(node, context)) File "C:\Program Files\Python2\lib\site-packages\django\template\debug.py" in render_node
  8. result = node.render(context) File "C:\Program Files\Python2\lib\site-packages\django\template\defaulttags.py" in render
  9. return self.nodelist_false.render(context) File "C:\Program Files\Python2\lib\site-packages\django\template\base.py" in render
  10. bits.append(self.render_node(node, context)) File "C:\Program Files\Python2\lib\site-packages\django\template\debug.py" in render_node
  11. result = node.render(context) File "D:\Users\Alexo\PycharmProjects\dev_wcobs_com\loginza\templatetags\loginza_widget.py" in render
  12. _return_path(context['request'], context['request'].path) File "C:\Program Files\Python2\lib\site-packages\django\template\context.py" in getitem
  13. raise KeyError(key)

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

vgarvardt commented 13 years ago

Do you have 'django.core.context_processors.request' in your TEMPLATE_CONTEXT_PROCESSORS?

xAlexo commented 13 years ago

added to settings.py

TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.request", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.contrib.messages.context_processors.messages" )

and go to

xAlexo commented 13 years ago

Попробовал создать чистый проект, тоже самое.

xAlexo commented 13 years ago

Вобщем проблема была во view, проблема чисто новичков, поэтому хорошо бы добавить пример :)

vgarvardt commented 13 years ago

В чем именно была проблема? При рендере шаблона не отдавался RequestContext?

xAlexo commented 13 years ago

ага

vgarvardt commented 13 years ago

Ок, допишу в документацию.

saippuakauppias commented 12 years ago

Для тех, кто в дальнейшем столкнётся с этой проблемой - нужно добавить 'django.core.context_processors.request' в TEMPLATE_CONTEXT_PROCESSORS.