Django_rest_api/backend/core/serializers.py

18 lines
467 B
Python
Raw Normal View History

from . import models
from rest_framework import serializers
from rest_framework.fields import CharField, EmailField
class ContactSerializer(serializers.ModelSerializer):
name = CharField(source="title", required=True)
message = CharField(source="description", required=True)
email = EmailField(required=True)
class Meta:
model = models.Contact
fields = (
'name',
'email',
'message'
)