29 lines
742 B
Python
29 lines
742 B
Python
|
from rest_framework import serializers
|
||
|
from .models import Word, Grid, Placement, Level
|
||
|
|
||
|
|
||
|
class LevelSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Level
|
||
|
fields = ["id", "level_number", "level_string"]
|
||
|
|
||
|
|
||
|
class WordSerializer(serializers.ModelSerializer):
|
||
|
level = LevelSerializer(many=False, read_only=True)
|
||
|
|
||
|
class Meta:
|
||
|
model = Word
|
||
|
fields = ["id", "word", "definition", "level"]
|
||
|
|
||
|
|
||
|
class GridSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Grid
|
||
|
fields = ["id", "words"]
|
||
|
|
||
|
|
||
|
class PlacementSerializer(serializers.ModelSerializer):
|
||
|
class Meta:
|
||
|
model = Placement
|
||
|
fields = ["id", "word", "grid", "coordinates_first_letter", "direction"]
|