Gjango - debugging argument of type <> is not iterable

24 views
Skip to first unread message

Shekar Tippur

unread,
May 29, 2015, 4:43:29 AM5/29/15
to django...@googlegroups.com

Hello,

Acurl post request is throwing this error:

Request Method:POST
Request URL:http://127.0.0.1:8000/setProfile/
Django Version:1.8
Exception Type:TypeError
Exception Value:
argument of type 'ReadOnlyField' is not iterable
Exception Location:/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/serializers.py in _get_model_fields, line 1243
Python Executable:/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
Python Version:3.4.3
Python Path:
['/Users/PycharmProjects/screens',
 '/Users/PycharmProjects/screens',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages'


Appreciate any input on how to troubleshoot this.

- Shekar

xutaodi...@gmail.com

unread,
May 29, 2015, 6:05:33 AM5/29/15
to django...@googlegroups.com
No
Note: you use 'ReadOnlyField' argument type is error, case modules call of django is incorrect

在 2015年5月29日星期五 UTC+8下午4:43:29,Shekar Tippur写道:

Shekar Tippur

unread,
May 29, 2015, 11:40:12 AM5/29/15
to django...@googlegroups.com
Hello,
Thanks for responding. I am not sure where in the code this is coming from. I have this code in my view. Not sure if this is the culprit. If it is, what is a better way to access this data.

class UserPrefSerializer(serializers.ModelSerializer):
class Meta:
owner = serializers.ReadOnlyField(source='owner.username')
model = UserPrefs
fields = (owner,
'name', 'value')
depth =
1

Shekar Tippur

unread,
May 29, 2015, 1:43:19 PM5/29/15
to django...@googlegroups.com
If I change this to

    class Meta:
owner = serializers.ReadOnlyField(source='owner.username')
model = UserPrefs
fields = ('owner',
'name', 'value')
depth =
1

I get a error: {"value":["This field is required."]}
Reply all
Reply to author
Forward
0 new messages