django-rest-framework icon indicating copy to clipboard operation
django-rest-framework copied to clipboard

Specify display/value pair for browsable api

Open elrapha opened this issue 9 years ago • 1 comments

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

elrapha avatar Oct 17 '17 00:10 elrapha

Hi,

The discussion group is the best place to take this discussion and other usage questions. Thanks!

xordoquy avatar Oct 17 '17 05:10 xordoquy