Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Last active August 29, 2015 14:25
Show Gist options
  • Save ShinJJang/eeb00e70f6b73388112d to your computer and use it in GitHub Desktop.
Save ShinJJang/eeb00e70f6b73388112d to your computer and use it in GitHub Desktop.
import json
from app.models import People
from django.http import HttpResponse
def add_peoples(request, room_id):
# request.body = '{"peoples": [{name:'a', phone:'001010}, {....}, {....}]}'
json_peoples = json.loads(request.body)
for json_people in json_peoples["peoples"]:
# room is real field name. _id is attr.
people = People.objects.create(name=json_people['name'], phone=json_people['phone'], room_id=room_id)
return HttpResponse(....)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment