serializers.py 515 B

123456789101112131415161718
  1. from rest_framework import serializers
  2. from .models import Environment, EnvironmentProject
  3. class EnvironmentSerializer(serializers.ModelSerializer):
  4. class Meta:
  5. model = Environment
  6. fields = ("id", "name")
  7. class EnvironmentProjectSerializer(serializers.ModelSerializer):
  8. name = serializers.StringRelatedField(source="environment")
  9. isHidden = serializers.BooleanField(source="is_hidden")
  10. class Meta:
  11. model = EnvironmentProject
  12. fields = ("id", "name", "isHidden")