I create two views that do the same thing but the first one use the
generic view and the second a render to response.
I don't understand why because both works but the second besides don't
passe the category object, don't load the
django.core.context_processors.media I set in settings.py.
So if I use the second view, the media I use with MEDIA_URL are not
loaded. Why happening this?
[...] href="{{ MEDIA_URL }}/style.css" [...]
from django.shortcuts import get_object_or_404, render_to_response
from coltrane.models import Entry, Category
from django.views.generic.list_detail import object_list
# this works and load everything
def category_detail(request, slug):
category = get_object_or_404(Category, slug=slug)
return object_list(request,
queryset=category.live_entry_set(),
template_name='coltrane/category_detail.html',
extra_context={ 'category': category })
# this doesn't load the django.core.context_processors.media
def category_detail(request, slug):
category = get_object_or_404(Category, slug=slug)
return render_to_response(
'coltrane/category_detail.html',
{ 'object_list': category.live_entry_set()}
)
--
Karim Gojux
www.karimblog.net
--
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