def post_seller (request): payload = json.loads(request.body) name = payload.get("name") seller_id = payload.get("seller_id") #status_seller = payload.get("status_seller") seller = Seller() seller.name = name seller.seller_id = seller_id #seller.status_seller= 'A' seller.save() return JsonResponse ({"sellers": seller.to_dict()})
def setUpTestData(cls): seller = Seller() seller.name = "sellerName" seller.seller_id = 1 Seller.objects.create(name="sellerName", seller_id=1) Product.objects.create(title="cadeira", price=5, id_product="32", qt_stock=8, seller_id=1, status='A') Product.objects.create(title="mesa", price=15, id_product="8", qt_stock=3, seller_id=1, status='A') Product.objects.create(title="computador", price=1000, id_product="6", qt_stock=1, seller_id=1, status='A')