Lets say I have two models in Django, and I'm using standard Viewsets and Serializers to expose endpoints.
ModelA has a ForeignKey field to ModelB. When I do an OPTIONS request to the ModelA endpoint it just lists it as a field, like below:
"actions": {
"POST": {
"pk": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"created": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Created"
},
"foreign_key_field": {
"type": "field",
"required": true,
"read_only": false,
"label": "Wcp"
},
}
}
I would like it to have a 'choices' property which pulls down every single instance of Model B. This way in my Angular frontend I can create a dropdown of all the choice.
I think I need to make a new MetaData class or somthing. But I can't find any solid way of doing this. I also think this functionality has changed in 3.X of DRF so old answers around the internet no longer help.
Cheers, Dean