django rest framework where to put business logic code example
Example 1: django rest framework business logic
class CoffeeShopService(object):
@staticmethod
def place_order(quantity):
# do the business logic here
return order_id
Example 2: django rest framework business logic
def order(request, quantity=1):
# Process the order by calling the mapped method
order_id = CoffeeShopService.place_order(quantity)
return HttpResponse({'order_id': order_id, mimetype='application/json')