devfzn
ca2156ef37
- 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
18 lines
467 B
Python
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'
|
|
)
|