def post(self, request, **kwargs): print request, kwargs expense = Expense( expense_type = ExpenseType.objects.get(id=self.CONTENT["expense_type"]["id"]), amount = self.CONTENT["amount"], event = Event.objects.get(id=self.CONTENT["event"]["id"]), payer = Participant.objects.get(id=self.CONTENT["payer"]["id"]), date = datetime.now() ) expense.save() expense.participants = [Participant.objects.get(id=participant["id"]) for participant in self.CONTENT["participants"]] expense.save()
weight_c_hotel = Weight( expense_type = expense_type_hotel, participant = participant_c, weight = 3.0 ) weight_c_hotel.save() expense_john_food = Expense( event = event, expense_type = expense_type_food, amount = 150.4, payer = participant_a, date = datetime.now() ) expense_john_food.save() expense_john_food.participants = [participant_a, participant_b] expense_john_food.save() expense_jack_food = Expense( event = event, expense_type = expense_type_food, amount = 55.7, payer = participant_b, date = datetime.now() ) expense_jack_food.save() expense_jack_food.participants = [participant_a, participant_b] expense_jack_food.save() expense_john_hotel = Expense(