serializers.py 468 B

1234567891011121314151617181920212223242526272829
  1. from sqlmodel_serializers import SQLModelSerializer
  2. from .models import Hero
  3. class HeroUpdate(SQLModelSerializer):
  4. class Meta:
  5. model = Hero
  6. optional = '__all__'
  7. fields = ('name', 'secret_name', 'age')
  8. class HeroRead(SQLModelSerializer):
  9. id: int
  10. full_name: str
  11. class Meta:
  12. model = Hero
  13. class HeroCreate(SQLModelSerializer):
  14. class Meta:
  15. model = Hero
  16. fields = ('name', 'secret_name', 'age')