Friday, February 25, 2011

grouping results in change_list admin view

I'd like to group the results shown on the admin change_list view
according to one (or more) fields. For example, if my model
had author and title fields, I might like a display that looks
like:

Author1:
Book1
Book2
Book3
Author2:
Book4
Author3:
Book5
Book6

So each author name appears only once, and it is visually separated from
the book titles.

I know that this is the sort of thing that {% regroup %} can handle, so
my question is whether I can easily adapt the default admin templates
to use {% regroup %}. I tried digging into this, but found that this
part of the page is generated by some complicated code in admin_list.py,
so it's not clear to me what the best way to accomplish this is.

Any suggestions or pointers?

Thanks,

Dan

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment