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
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
On Monday, 13 July 2015 01:50:11 UTC+1, 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.
>
> This in an example code i made up to illustrate my problem:
> # Models
> class Book(models.Model):
> submitted_by
3 matches
Mail list logo