On 5/26/06, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > > I would do something like this: > > def related_tags(tag_name): > return > Tag.objects.filter(paper__tag__name__exact=tag_name).exclude(name__exact=tag_name).distinct() > > Filter expression reads like "all tags that linked to any papers that > linked to this tag". Exclude and distinct should be self-explanatory. > > Note that with this Tag architecture the search is constrained to only > specific model (Paper in this case). If you have these same tags linked > to another models you won't have them as "related". But this what one > wants usually anyway. >
Ahh, that's perfect. Is there any way I could use this with the 'object_list' generic view, or will I just have to roll my own view to get this one going? It's easy enough to do a view for it, but it *feels* like there'd be a way to pass some 'extra_context' to 'object_list', such that it can dynamically build QuerySets. Maybe if I could pass arguments to a callable in 'extra_context' Jay P. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---