mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Fixed study group message serializer
This commit is contained in:
parent
288a1edd5e
commit
07c57238a9
1 changed files with 4 additions and 3 deletions
|
@ -1,13 +1,14 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from .models import Message
|
from .models import Message
|
||||||
from accounts.models import CustomUser
|
from accounts.models import CustomUser
|
||||||
|
from study_groups.models import StudyGroup
|
||||||
|
|
||||||
|
|
||||||
class MessageSerializer(serializers.ModelSerializer):
|
class MessageSerializer(serializers.ModelSerializer):
|
||||||
user = serializers.SlugRelatedField(
|
user = serializers.SlugRelatedField(
|
||||||
queryset=CustomUser.objects.all(), slug_field='full_name', required=False)
|
queryset=CustomUser.objects.all(), slug_field='full_name', required=True)
|
||||||
study_group = serializers.CharField(
|
study_group = serializers.SlugRelatedField(
|
||||||
source='subject.Subject', read_only=True, required=False)
|
queryset=StudyGroup.objects.all(), slug_field='name', required=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Message
|
model = Message
|
||||||
|
|
Loading…
Reference in a new issue