Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ScheduleList(ListView):
- model = Schedule
- queryset = Schedule.objects.all().select_related()
- context_object_name = "schedule_list"
- def get_context_data(self, **kwargs):
- # get all context Schedule class
- context = super().get_context_data(**kwargs)
- # add context about all rights
- rights_list = [i.name for i in RightsList.objects.all()]
- context["rights_list"] = rights_list
- # add fields
- field_list = []
- field_list += [i.verbose_name for i in Moderator._meta.get_fields()[2:6]]
- field_list += [i.verbose_name for i in Schedule._meta.get_fields()[1:3]]
- # field_list += rights_list
- context["field_list"] = field_list
- # add rights to moderators
- # for i in context["schedule"]:
- # moderator_name = i["moderator"]["name"]
- # i["moderator"]["rightslist"] = queryset.filter(
- # moderator__name=moderator_name
- # )[0].moderator.rightslist.all()
- return context
Advertisement
Add Comment
Please, Sign In to add comment