I would like show list of clients and show tags assigned to them but I have problem because I have my tags in other table and I dont know how to connect data together. Clients can have couple of tags or none of that. Which way is correct to do this? Can you advice me something? I need one variable with tags separated comma or objects with tags which I can use in template engine.
Views.py:
@user_passes_test(lambda u: u.is_staff, login_url='/account/login/')
def client_list(request):dict = {}dict['clients'] = Client.objects.all()return render(request, 'panel/client/list.html', dict)
Models.py:
class Client(models.Model):id = models.OneToOneField(User, on_delete=models.CASCADE, unique=True, primary_key=True)uuid = models.UUIDField(default=uuid.uuid4, editable=False)name = models.CharField(max_length=256, unique=True)class TagsClientChoices(models.Model):name = models.CharField(max_length=80, unique=True)class TagsClientList(models.Model):tag_id = models.ForeignKey('TagsClientChoices')client = models.ForeignKey('Client', blank=True, null=True)