-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use serializer to save data given by user
- Loading branch information
1 parent
7c27bf3
commit 9cab7d1
Showing
3 changed files
with
37 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from rest_framework import serializers | ||
|
||
from django.apps import apps | ||
|
||
|
||
class OptionSerializer(serializers.ModelSerializer): | ||
question = serializers.PrimaryKeyRelatedField(many=False, queryset=apps.get_app_config("masteriqapp").get_model("Question").objects.all()) | ||
# question = serializers.SlugRelatedField(many=False, slug_field='id', | ||
# queryset=apps.get_app_config("masteriqapp").get_model( | ||
# "Question").objects.all()) | ||
#question_id = serializers.UUIDField() | ||
class Meta: | ||
model = apps.get_app_config("masteriqapp").get_model("Option") | ||
fields = ['text', 'is_correct', 'question'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters