django - Sending many json objects with one object json -
i'm using django-restful-framework , django 1.5
i having trouble post. hard explain let start example.
models.py
class project(models.model): project_name = models.charfield(max_length=100) project_description = models.charfield(max_length=100) class task(models.model): project = models.foreignkey(project, related_name='task') task_title = models.charfield(max_length=100)
serializer.py
class taskserializer(serializers.modelserializer): class meta: model = task fields = ('task_title') class projectserializer(serializers.modelserializer): task = taskserializer(many=true) class meta: model = album fields = ('project_name', 'project_description', 'task')
when this, viewsets.modelviewset in django-rest-framework displays text field task :
but gives me error when posting without filling in task field :
add() argument after * must sequence, not nonetype
is there nice way connect project task can create project without task, , create many tasks want inside project? /project , /task display same form though there different fields in model.
i'm using django-rest-framework default view test api now.
p.s i'm trying write clear possible, please let me know if i'm missing better help.
on django rest page, says:
note nested relationships read-only.
"read only" make posting little difficult ;)
Comments
Post a Comment