diff --git a/topologie/models.py b/topologie/models.py index 2eaa3364..954fa9c4 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -611,16 +611,19 @@ class Building(AclMixin, RevMixin, models.Model): """Returns all ap of the building""" return AccessPoint.all_ap_in(self) - @cached_property - def cached_name(self): - return self.__str__() - - def __str__(self): + def get_name(self): if Dormitory.objects.count() > 1: return self.dormitory.name + " : " + self.name else: return self.name + @cached_property + def cached_name(self): + return self.get_name() + + def __str__(self): + return self.cached_name + class Port(AclMixin, RevMixin, models.Model): """ Definition d'un port. Relié à un switch(foreign_key), diff --git a/topologie/views.py b/topologie/views.py index c8be33b7..9781a7d2 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -217,7 +217,7 @@ def index_port(request, switch, switchid): @can_view_all(Room) def index_room(request): """ Affichage de l'ensemble des chambres""" - room_list = Room.objects + room_list = Room.objects.select_related('building__dormitory') room_list = SortTable.sort( room_list, request.GET.get('col'),