Skip to content

Commit

Permalink
Enhance QuestionViewSet to order questions by creation time and add o…
Browse files Browse the repository at this point in the history
…rdering fields
  • Loading branch information
yunho7687 authored and thnorton committed Feb 12, 2025
1 parent 1de663b commit fef862d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/api/question/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ class QuestionViewSet(viewsets.ModelViewSet):
search_fields (list): The fields to search in the viewset.
filterset_fields (list): The fields to filter in the viewset.
"""
queryset = Question.objects.all()
queryset = Question.objects.all().order_by("-time_created")
serializer_class = QuestionSerializer
filter_backends = [DjangoFilterBackend, filters.SearchFilter]
search_fields = ['name']
filterset_fields = ['mark', 'answers__value']
ordering_fields = ['time_created', 'time_modified', 'diff_level', 'mark']

# override the create method
def create(self, request, *args, **kwargs):
Expand Down

0 comments on commit fef862d

Please sign in to comment.