mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-16 22:09:25 +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 .models import Message
|
||||
from accounts.models import CustomUser
|
||||
from study_groups.models import StudyGroup
|
||||
|
||||
|
||||
class MessageSerializer(serializers.ModelSerializer):
|
||||
user = serializers.SlugRelatedField(
|
||||
queryset=CustomUser.objects.all(), slug_field='full_name', required=False)
|
||||
study_group = serializers.CharField(
|
||||
source='subject.Subject', read_only=True, required=False)
|
||||
queryset=CustomUser.objects.all(), slug_field='full_name', required=True)
|
||||
study_group = serializers.SlugRelatedField(
|
||||
queryset=StudyGroup.objects.all(), slug_field='name', required=True)
|
||||
|
||||
class Meta:
|
||||
model = Message
|
||||
|
|
Loading…
Reference in a new issue