-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serializer.data returns ReturnDict and OrderedDict instead of dict object. #2364
Comments
There's some information lacking to be completely helpful, like how exactly are you doing to "test to see if it serializes properly..." but you should be able to do something like the following depending on how you're using the serializer. serializer = YourSerializer(instance)
assert serializer.data == {'id': 1, 'username': 'admin'} There are many examples on doing this around the test cases that should help out more. Other than that if you need more help with this, usage questions should be asked on the mailing list, Stack Overflow or IRC. |
@jpadilla I already ran into that one. I'll work on the test case tonight. |
Also note that this is likely the root cause for #2360 |
The 'ReturnDict' type is mostly just an implementation detail. It is an ordered dictionary type. You shouldn't need to convert it to a ppdict primitive. |
how to test the serializer.data(ReturnDict) against python dictionay({'akey': 1} ). |
This works just fine...
|
Didn't manage to reproduce it. Will open a ticket if I face this again. |
Just fall on it again. |
Forget the previous comment. |
I have written a model serializer class for a model. When I test to see if it serializes properly I get following error.
AssertionError: ReturnDict([(u'id', 1), ('apple', OrderedDict([(u'id', 1), ('data', u'this is a apple data.')])) ...
I tried converting it to dict wrapping aserializer.data to dict function like
dict(aserializer.data)
I get following error.
AssertionError: {'status': False, 'http': OrderedDict([(u'id', 1), ...
How to get dictionary data from a serializer.
The text was updated successfully, but these errors were encountered: