namedtuple rendered as list instead of dict #8796
Unanswered
Credentive-Sec
asked this question in
Potential Issue
Replies: 2 comments 2 replies
-
I have been able to create what I want by manually creating the dict:
However, it still feels like DRF should render the named tuple as a dict automatically. |
Beta Was this translation helpful? Give feedback.
0 replies
-
so apparently there are some sort of serialization issue for UUID? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a django model that has a custom property which returns a list of named tuples generated with values_list(named=True). Example output:
[Row(over=UUID('1de7104d-0a6b-49fa-98e5-1538fcf9346d'), under=UUID('ef9e4095-a56e-43c5-a578-1559bd78fbba')), Row(over=UUID('1de7104d-0a6b-49fa-98e5-1538fcf9346d'), under=UUID('844dccc5-d15a-4c97-9c29-200facf59eda')),
<...>]
This is rendered in DRF as a list of ordinary tuples, eg:
Wheras I might expect it to be rendered as a dict, e.g.
Is this intentional? Does it make more sense for a named tuple to be converted into a dict rather than a list?
Beta Was this translation helpful? Give feedback.
All reactions