Guest User

Untitled

a guest
Nov 8th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. class ScheduleList(ListView):
  2.     model = Schedule
  3.     queryset = Schedule.objects.all().select_related()
  4.     context_object_name = "schedule_list"
  5.  
  6.     def get_context_data(self, **kwargs):
  7.         # get all context Schedule class
  8.         context = super().get_context_data(**kwargs)
  9.         # add context about all rights
  10.         rights_list = [i.name for i in RightsList.objects.all()]
  11.         context["rights_list"] = rights_list
  12.         # add fields
  13.         field_list = []
  14.         field_list += [i.verbose_name for i in Moderator._meta.get_fields()[2:6]]
  15.         field_list += [i.verbose_name for i in Schedule._meta.get_fields()[1:3]]
  16.         # field_list += rights_list
  17.         context["field_list"] = field_list
  18.         # add rights to moderators
  19.         # for i in context["schedule"]:
  20.         #     moderator_name = i["moderator"]["name"]
  21.         #     i["moderator"]["rightslist"] = queryset.filter(
  22.         #         moderator__name=moderator_name
  23.         #     )[0].moderator.rightslist.all()
  24.         return context
Advertisement
Add Comment
Please, Sign In to add comment