Tuesday, June 29, 2010

Re: context porcessors request.context media_url breaks admin

Hi Tom if you read my original post you will realise that the error is
being caused by setting of context processors to media_url (see
original post).
When context processors are active the {media_url} tag works
perfectly, but breaks the admin.

If I comment out :
settings.py
#TEMPLATE_CONTEXT_PROCESSORS =
('portfolio.context_processors.media_url',)
and
urls.py
#from django.template import RequestContext

the admin then works.

I believe this has nothing to do with a template error, but some kind
of conflict. To satisfy mystic meg, I have included error with
traceback:

TemplateSyntaxError at /admin/
Caught an exception while rendering: userRequest Method: GET
Request URL: http://127.0.0.1:8000/admin/
Exception Type: TemplateSyntaxError
Exception Value: Caught an exception while rendering: user
Exception Location: C:\Python26\lib\site-packages\django\template
\debug.py in render_node, line 81
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4
Python Path: ['c:\\django\\portfolio_root', 'C:\\Python26\\lib\\site-
packages\\html5lib-0.90-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_page_cms-1.1.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_cms-2.0.2-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_admin_tools-0.2.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages
\\django_friends-0.1.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_schedule-0.1.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\python_dateutil-1.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_forum-r53-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_notification-0.1.4-py2.6.egg', 'C:\\Python26\\lib\\site-
packages\\django_pagination-1.0.5-py2.6.egg', 'C:\\Python26\\lib\\site-
packages\\sphinx-0.6.5-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\docutils-0.6-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\jinja2-2.4.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\pygments-1.3.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_avatar-1.0.4-py2.6.egg', 'C:\\Python26\\lib\\site-packages\
\django_locations-0.1.0-py2.6.egg', 'C:\\Windows\\system32\
\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\
\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\
\Python26', 'C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\
\site-packages\\PIL', 'c:\\python26\\lib\\site-packages']
Server time: Tue, 29 Jun 2010 13:36:03 +0100

Template error
In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\index.html, error at line 56

Caught an exception while rendering: user
46 {% endif %}

47 </div>

48 {% endblock %}

49
50 {% block sidebar %}

51 <div id="content-related">

52 <div class="module" id="recent-actions-module">

53 <h2>{% trans 'Recent Actions' %}</h2>

54 <h3>{% trans 'My Actions' %}</h3>

55 {% load log %}

56 {% get_admin_log 10 as admin_log for_user user %}

57 {% if not admin_log %}

58 <p>{% trans 'None available' %}</p>

59 {% else %}

60 <ul class="actionlist">

61 {% for entry in admin_log %}

62 <li class="{% if entry.is_addition %}addlink{% endif %}
{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}
deletelink{% endif %}">

63 {% if entry.is_deletion %}

64 {{ entry.object_repr }}

65 {% else %}

66 <a
href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.1.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.markup',
'portfolio']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\index.html, error at line 56
Caught an exception while rendering: user
46 : {% endif %}


47 : </div>


48 : {% endblock %}


49 :


50 : {% block sidebar %}


51 : <div id="content-related">


52 : <div class="module" id="recent-actions-module">


53 : <h2>{% trans 'Recent Actions' %}</h2>


54 : <h3>{% trans 'My Actions' %}</h3>


55 : {% load log %}


56 : {% get_admin_log 10 as admin_log for_user user
%}


57 : {% if not admin_log %}


58 : <p>{% trans 'None available' %}</p>


59 : {% else %}


60 : <ul class="actionlist">


61 : {% for entry in admin_log %}


62 : <li class="{% if entry.is_addition %}addlink{%
endif %}{% if entry.is_change %}changelink{% endif %}{% if
entry.is_deletion %}deletelink{% endif %}">


63 : {% if entry.is_deletion %}


64 : {{ entry.object_repr }}


65 : {% else %}


66 : <a
href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>


Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in
get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
wrapper
196. return self.admin_view(view, cacheable)(*args,
**kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
inner
186. return view(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in
index
374. context_instance=context_instance
File "C:\Python26\lib\site-packages\django\shortcuts\__init__.py" in
render_to_response
20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "C:\Python26\lib\site-packages\django\template\loader.py" in
render_to_string
108. return t.render(context_instance)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
178. return self.nodelist.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
779. bits.append(self.render_node(node, context))
File "C:\Python26\lib\site-packages\django\template\debug.py" in
render_node
71. result = node.render(context)
File "C:\Python26\lib\site-packages\django\template\loader_tags.py" in
render
97. return compiled_parent.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
178. return self.nodelist.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
779. bits.append(self.render_node(node, context))
File "C:\Python26\lib\site-packages\django\template\debug.py" in
render_node
71. result = node.render(context)
File "C:\Python26\lib\site-packages\django\template\loader_tags.py" in
render
97. return compiled_parent.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
178. return self.nodelist.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
779. bits.append(self.render_node(node, context))
File "C:\Python26\lib\site-packages\django\template\debug.py" in
render_node
71. result = node.render(context)
File "C:\Python26\lib\site-packages\django\template\loader_tags.py" in
render
24. result = self.nodelist.render(context)
File "C:\Python26\lib\site-packages\django\template\__init__.py" in
render
779. bits.append(self.render_node(node, context))
File "C:\Python26\lib\site-packages\django\template\debug.py" in
render_node
81. raise wrapped

Exception Type: TemplateSyntaxError at /admin/
Exception Value: Caught an exception while rendering: user

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment