Open buedaswag opened 3 years ago
in the prep course portal i fixed it like this
def get_queryset(self):
# no need to call super().get_queryset() because
# "By default, it returns the value of the queryset attribute"
# https://docs.djangoproject.com/en/3.2/topics/class-based-views/generic-display/#dynamic-filtering
slackid = self.request.GET.get("slackid")
learning_unit = self.request.GET.get("learning_unit")
exercise_notebook = self.request.GET.get("exercise_notebook")
# TODO this is inneficient, is there a better way?
queryset = self.queryset.all()
if slackid:
queryset = queryset.filter(slackid=slackid)
if learning_unit:
queryset = queryset.filter(learning_unit=learning_unit)
if exercise_notebook:
queryset = queryset.filter(exercise_notebook=exercise_notebook)
return queryset.order_by("-learning_unit", "-exercise_notebook", "-created")
´´´
god its ugly, but it sure works
when i filter for both
can_graduate
anduser_id
, i expect the results shown in the page to be filtered, however, only the first filter is appliedhttps://portal.lisbondatascience.org/academy/instructor/students/?can_graduate=False&user_id=111