Django_rest_api/backend/core/serializers.py
devfzn ca2156ef37
Creación del primer endpoint
- Modelo contacto en core/models.py
- Creación utils/model_abstracts para heredar y usar id con valor uuid
- Serializador en core/serializers hereda de rest_frameworks.serializers
- Vista contacto en core/views.py
- Registro de app en admin
- Migraciones
2023-03-29 18:35:23 -03:00

18 lines
467 B
Python

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'
)