I have model with ManyToManyField:
class Action(models.Model):
title = models.CharField('title', max_length=160)
countries = models.ManyToManyField('Country', null=True, blank=True)
class Country(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=255, blank=True)
Every action has an url to page with description. Every country has an icon with flag. Action may have 2 or more countries. So output should be like this:
- Country 1, County 2
- Action
- Action
- Action
- Country 3, Country 4
- Action
- Country 1
- Action
- Action
- Country 3
- Action
I don't know how to resolve the problem. Tag {% regroup %} doesn't work correctly because it groups only by first country in each action.