def create_new_paper(**kwargs): if email_has_more_than_five_questions_open(kwargs['sent_to']): #Do not create a new paper and return http response with error code 400 response = HttpResponse() response.status_code = 400 response.reason_phrase = "Too many questions open for this e-mail" return response else: #Insert Data into DB #See if a DB record from the sender already exists. the_sender = checkExistingEmail(kwargs['sender']) the_sender.ip = kwargs['ip'] the_sender.save() new_paper = Paper(sender=the_sender, sent_to=kwargs['sent_to']) new_paper.code = uuid.uuid4() new_paper.save() new_question = Question(sender=the_sender, paper=new_paper, question_text=kwargs['question'], question_type=kwargs['question_type']) new_question.save() new_answers = create_answers_objects(the_sender, new_paper, new_question, kwargs['answers'], kwargs['selected_answer']) test = Answer.objects.bulk_create(new_answers) test.save()