Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error when saving new community question #147

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/masteriqapp/views/QuestionView.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QuestionView(viewsets.ViewSet):
def new(self, request, pk):
category = get_object_or_404(self.queryset, pk=pk)
if 'question' in request.session:
actual_question = self.question_model.objects.get(pk=request.session['question'])
actual_question = get_object_or_404(self.question_model.objects.all(), pk=request.session['question'])
if actual_question.category == category:
serializer = QuestionSerializer(actual_question)
return Response(serializer.data, status=status.HTTP_200_OK)
Expand Down Expand Up @@ -84,7 +84,7 @@ def new_community(self, request):
status=status.HTTP_400_BAD_REQUEST)

for option in datas['options']:
option_serializer = OptionSerializer(data={"text": option, "is_correct": False, "question": 3})
option_serializer = OptionSerializer(data={"text": option, "is_correct": False, "question": question.id})

if option_serializer.is_valid():
option_serializer.save()
Expand Down
Loading