Formatting a permissions QuerySet so that it just displays the name column

Formatting a permissions QuerySet so that it just displays the name column

I am trying to list the permissions specific to a model through a query. The goal is to just display the "name" part of the QuerySet. I'm only able to get the output below through the tag: {{ permissions }}

I am trying to list the permissions specific to a model through a query. The goal is to just display the "name" part of the QuerySet. I'm only able to get the output below through the tag: {{ permissions }}

<QuerySet [<Permission: cms | Account meta | Can add Account meta>, <Permission: cms | Account meta | Can change Account meta>, <Permission: cms | Account meta | Can delete Account meta>, <Permission: cms | Account meta | Allows the user to log in as others>, <Permission: cms | Account meta | Allows a user to deactivate/delete other users>, <Permission: cms | Account meta | Allows a user to edit site and role details>, <Permission: cms | Account meta | Can export user details>, <Permission: cms | Account meta | Can view Account meta>]>

models.py

class Account(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    site = models.CharField(max_length=50, choices=(('all', 'all'), ('danielk', 'danielk'), ('flis', 'flis'), ('vmusic', 'vmusic')), blank=True)
    site_role = models.CharField(max_length=50, choices=(('Administrator', 'Administrator'), ('Moderator', 'Moderator'), ('Editor', 'Editor')))
    phone_number = models.CharField(max_length=8)
    birth_date = models.DateField()
    street_adress = models.CharField(max_length=255)
    note = models.TextField(blank=True);
    zip_code = models.CharField(max_length=4)
    city = models.CharField(max_length=255)

def formatedPhone(self, country=None):
    return phonenumbers.parse(Account.phone_number, "NO")

"""
def __str__(self):
    return "%s %s" % (self.User.first_name, self.user.last_name)
"""

def get_absolute_url(self):
    return reverse('account-detail', kwargs={'pk': self.pk})

class Meta:
    verbose_name = 'Account meta'
    verbose_name_plural = 'Accounts meta'
    permissions = (
        ("has_user_hijack_permission", "Allows the user to log in as others"),
        ("has_user_management", "Allows a user to deactivate/delete other users"),
        ("has_user_site_edit", "Allows a user to edit site and role details"),
        ("has_user_takeout", "Can export user details"),
    )

views.py

class cms_users_user_permissions(generic.DetailView):
    model = Account
    template_name = 'cms/users/cms-users-user-permissions.html'

def get_context_data(self, **kwargs):
    context = super().get_context_data(**kwargs)
    context["permissions"] = Permission.objects.filter(content_type=ContentType.objects.get_for_model(Account))
    #context['permissions'] = Permission.objects.filter(content_type_id=7)
    return context


django

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Python Django Tutorial | Django Course

🔥Intellipaat Django course: https://intellipaat.com/python-django-training/ 👉This Python Django tutorial will help you learn what is django web development &...

django-allauth Django REST Framework |teratail

Djangoアプリを、当初は Django REST Framework (DRF) を使わずに作成しました。(認証パッケージは、 django-allauthを使用)アプリリリース後に、DRFも追加で導入して、DRFで作成したAPIでのデ

Django REST Framework Course for Beginners

In this article we are going to talk about Django REST Framework Course for Beginners, also for more information you can check the complete video for th

Хранение изображений с помощью Django/Django REST

Проблема Мне в ходе разработки часто приходится работать с моделями, в которых должны быть изображения. Для удобной организации я использую древовидную структуру...

How to Integrate Django to any Javascript Front End // Django to React // Django to Angular

Learn the basic technique to Integrate Django to any Javascript Front End // Django to React // Django to Angular