Hi,

Malcolm Tredinnick wrote:
> In the object_list view, you are given an "object_list" parameter, which
> is a list of all the objects for that page. To display them, you will be
> doing something like
>
>         {% for folder in object_list %}
>
> to iterate over that list. Inside that loop, you should then be able to
> do 
>
>         {% for media in folder.media_set.all %}
>         
> and so on.
>   
Thanks for the reply.
The thing is I wanted to show the media_set for a given folder (pass
something like <object_id> with the detail view). I finished writing a
wrapper for this which looks like this:

def custom_listmedia(request, id):
    from django.views.generic.list_detail import object_list
    obj = get_object_or_404(Folder, folders_id=id)
    return object_list(request,obj.media_set.all(),paginate_by=15,page=page)

This works quite well.
As I see it there is no way to limit the object_list view by parameters,
rigth? It is just a flat list of objects in a table.

> QuerySets are lazy. Since pagination only wants, say, 10 items, it will
> end up running "queryset[:10]" and only when the results are needed will
> the query be turned into SQL and run. In this case, that will convert it
> into a query involving a LIMIT clause, so you don't end up selecting
> every single result; just the ones you need.
>
> Am I making any of this clearer? Or just confusing things further? It's
> always a bit difficult to know how much detail to put into these
> postings, so let me know if I've put too little in this case.
>   
No, that sounds perfectly reasonable. It was just confusing that you
have to give obj.objects.all() for viewing a single entry. I just didn't
realize it did something like obj.objects.all().get(pk=..) behind the scene.
Thanks again for the clarification.

Regards,
Sean

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to