On Sep 2, 2:45 pm, Karim Gorjux <lemieli...@gmail.com> wrote:
> Working on the Coltrane's Book :-) ...
>
> 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 Gojuxwww.karimblog.net
See here for an explanation:
http://docs.djangoproject.com/en/1.2/ref/templates/api/#subclassing-context-requestcontext
especially the "Note" box a screen or so down.
--
DR.

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

Reply via email to