How to add a function result from a model to a list?

How to add a function result from a model to a list 'subdom()'

models.py

class Hromady(models.Model): ...

    def subdom(self):
        if self.alias:
            sub = self.alias
        else:
            sub = self.code.lower()
        return sub

views.py

def index(request):
    hromads = Hromady.objects.all()
    for hr in hromads:
        print(hr.subdom()) # ok

    hrom = hromads.annotate(obj_count=Count('object', filter=Q(object__state=1)))
    map_hrom = list(hrom.values('region', 'district', 'locality', 'type', *****subdom()*****???, 'obj_count'))
Вернуться на верх