On Mon, 2006-07-24 at 11:41 +0000, sean wrote:
> Hi,
> I'm having a hard time getting the generic list view to work for a set
> of related objects.
> I have two models, Folder and Media, where Media has a foreign key
> relationship to Folder. I want to use generic views to access all the
> media related to a specific folder but I can't seem to get the queryset
> argument right.
> 
> Something like Folder.objects.media_set.all() doesn't work because the
> manager has no attribute media_set.
> Folder.media_set.all()  also doesn't work, because that would need an
> object instance.
> 
> The corresponiding url line is:
> (r'^viewmedia/f(?P<object_id>\d+)/page(?P<page>\d+)/$',
> 'django.views.generic.list_detail.object_list', info_dict),
> 
> Any suggestions?

Inside your template, once you have a particular Folder instance (say,
"object"), object.media_set.all() will retrieve what you want. Getting
the list of folders in the queryset you pass to the generic view will
therefore be enough: you can dive deeper on an instance-by-instance
basis inside the template.

Does that do what you want, or am I missing something?

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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