15 lines
484 B
Python
15 lines
484 B
Python
from rest_framework import serializers
|
|
from .models import Coaster
|
|
|
|
|
|
class CoasterSerializer(serializers.ModelSerializer):
|
|
creator_username = serializers.ReadOnlyField(source='creator.username')
|
|
|
|
class Meta:
|
|
model = Coaster
|
|
fields = [
|
|
'id', 'creator_username', 'challenge', 'name',
|
|
'anchors', 'acceleration_strips', 'created_at', 'updated_at',
|
|
]
|
|
read_only_fields = ['id', 'creator_username', 'created_at', 'updated_at']
|