def post(self, request): serializer = AddToCartSerializer(data=request.data) if serializer.is_valid(): serializer.save() return createResponse(True, "Success", serializer.data, 'data') else: return createResponse(False, "Fail", serializer.errors, 'errors')
def post(self, request, format=None): serializer = NurseryRegisterSerializer(data=request.data) if serializer.is_valid(): serializer.save() user = User.objects.get(username=request.data['username']) refresh = get_tokens_for_user(user) access = refresh['access'] else: return createResponse(False, "Registration Failed", serializer.errors, "errors") return createResponse(True, "Nursery Successfully Registered", { 'details': serializer.data, 'access': access }, 'data')
def post(self, request, format=None): serializer = LoginSerializer(data=request.data) if serializer.is_valid(): serializer.save() user = User.objects.get(username=request.data['username']) refresh = get_tokens_for_user(user) access = refresh['access'] return createResponse(True, "Successfully logged In", { 'username': serializer.data['username'], 'access': access }, 'data') else: return createResponse(False, "Login failed", serializer.errors, "errors")
def get(self, request, format=None): obj = NurseryPlant.objects.all() serializer = GetNurseryPlant(obj, many=True) return createResponse(True, 'Sucess', serializer.data, 'data')