1👍
You are missing your views.py code here, but I am guessing you are using ListCreateAPIView out of the box. It turns out that django rest framework does not support automatically creating nested objects out of the box, so you’ll need to add your own code to address that functionality. There is good documentation here:
http://www.django-rest-framework.org/api-guide/serializers/#writable-nested-representations
2👍
Are you sure it’s not actually a string that is successful rather than a dictionary? I’ve ran into this problem on the Django side, don’t know much about Android.
With python it would be:
import json
your_dict = {...}
# this stringifies the dict
json.dumps(your_dict)
I know you’re doing this on the client, so the code above won’t be your answer, but it’s an idea and hopefully it helps!
- How to get data from database without models in django?
- Django – custom 403 template
- Extending Django's Generic Views
- How to locally test Django's Sites Framework
2👍
You can try this in an alternative way by changing the QuestionSerializer:
class QuestionSerializer(serializers.ModelSerializer):
answers = serializers.SerializerMethodField()
class Meta:
model = Question
fields = ('id', 'answers', 'created_at', 'text', 'user_id',)
def get_answers(self,obj):
ans_set = AnswerSerializer(Answer.objects.filter(question=obj),many=True)
return ans_set
- How to update a file location in a FileField?
- Django-admin.py and virtualenv issue on Windows
- Django templates extending and CSS
- Django/Webpack – How to serve generated webpack bundles with webpack dev server
2👍
I think that the data is not well-formed for that service….
{"text":"gf or ed","answers":[{"text":"gf","votes":0,"id":null},{"text":"ed","votes":0,"id":null}],"user_id":"temp user id"}
‘Picture’ doesn’t exist, you don’t send it from android… And Django makes fields ‘required’ by default, so it should be causing your problem …
Have you got any traces from python? Try to debug it.
- How to implement sorting in Django Admin for calculated model properties without writing the logic twice?
- Django serving media files (user uploaded files ) in openshift