I have field like this,
models.py
from django.db import models as m
class Faculty(m.IntegerChoices):
Arts = 1, 'Arts',
Scienece = 2, 'Sceience'
Other = 3 ,'Other'
and it is used as reference in other models.
Howeber, now I want to get the list by API rest framework.
For example if it is not IntegerChoices
but Model
I can use the rest framework with view
and serializer
class MyModelViewSet(viewsets.ModelViewSet):
queryset = sm.Faculty.objects.all()
serializer_class = s.FormSelectorSerializer
class MyModleSerializer(ModelSerializer):
detail = serializers.JSONField()
class Meta:
model = sm.MyModel
fields = ('id')
I can use the rest framework like this ,
However for IntegerChoices
, How can I do the equivalent to this thing?
Or is it possible?