Another approach would be to build a list of dictionaries based on the
query and pass this to the template instead of the pure llst of books:
[{
publisher: 'Publisher X',
books: ['Book A', 'Book B']
}],....
So the logic remains in the code and not in the template.
Kai
Am 13.07.2015 um 17:12 schrieb Scot Hacker:
On Sunday, July 12, 2015 at 5:50:11 PM UTC-7, Andrea wrote:
Hello. I'm new to both django and python. Been trying to figure
out how to group items from a model for hours now.
Check out the `regroup` template tag:
https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#regroup
It can probably save you from writing custom code for this.
./s
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/40de5ec2-c4d1-4cf2-8e4e-766dea21460b%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/40de5ec2-c4d1-4cf2-8e4e-766dea21460b%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/55A41FB0.8000906%40gmx.de.
For more options, visit https://groups.google.com/d/optout.