Oh, the answer here was to use the regroup template tag. Thanks Magus.
--
Milan
On Fri, Nov 7, 2008 at 4:37 PM, Milan Andric <[EMAIL PROTECTED]> wrote:
>
> Any thoughts on this one? Just checking.
>
> Thanks.
>
> On Nov 6, 9:06 pm, "Milan Andric" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I have a view that displays hundreds of applications based on some filter
> > params. But I want to render the actual template based on user (an fkey)
> > and list their applications as sub objects. but only the applications
> that
> > were filtered on. bleh.
> >
> > So in the view I do something like:
> >
> > # define queryset params from query string.
> > query_params = {
> > 'status' : request.GET.get('status', None),
> > 'complete' : request.GET.get('complete', None),
> > 'workshop__in' : request.GET.getlist('workshop__in'),
> > 'user__is_active':True,
> > }
> > # form params need to be integers
> > query_params['workshop__in'] = [int(i) for i in
> > query_params['workshop__
> > in']]
> >
> > # None or '' means don't filter on it. Remove it so
> > # Foo.objects.filter() will give the correct results.
> > for key in query_params.keys():
> > if query_params[key] == None or query_params[key] == '':
> > del query_params[key]
> >
> > # Pass query dict we just built as keyword args to filter().
> > queryset = Application.objects.filter(**query_params)
> >
> > This gives me applications based on the query params that I iterate over
> in
> > my template. The problem is I want to change the template now to display
> > based on the person/user foreign key and have the applications listed
> > underneath the person. If I send a queryset of Users to the template
> then I
> > can get a list of users but I lose the applications filters. Or is this
> a
> > good solution for some kind of querying filter/template tag? If I send a
> > list of applications then I can't list by user.
> >
> > Any suggestions?
> >
> > Thank you,
> >
> > --
> > Milan
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---