django-rest-framework
django-rest-framework copied to clipboard
Specify display/value pair for browsable api
My model is as (only pseudocode)
Country:
Name = ...
Code = ...
__unicode__: return "Name - Code"
__str__: return "Name - Code"
I have successfully created a custom foreign key field that displays "Name - Code" on read but only accepts the Code on write. This works fine using Postman. However in my Browserble api I see a dropdown of countres displayed as "Name - Code" but when i post it posts the Name field of the model.
I need send the Code field from the browsable api. How do I specify this and where. Primarily how do i specify what the display/value pair should be for a foreign key dropdown field in the browsable api
Hi,
The discussion group is the best place to take this discussion and other usage questions. Thanks!