diff --git a/django-postgres/README.md b/django-postgres/README.md index 6d3f815..16d6192 100644 --- a/django-postgres/README.md +++ b/django-postgres/README.md @@ -1,6 +1,6 @@ # User Data CRUD Application -A sample user data CRUD app to test Keploy integration capabilities using [Django](https://www.djangoproject.com/) and PostgreSQL.
+A sample user data CRUD app to test Keploy integration capabilities using [Django](https://www.djangoproject.com/) and [PostgreSQL](https://www.postgresql.org/).
Make the following requests to the respective endpoints - 1. `GET /user/` - To get all the data at once. @@ -138,18 +138,4 @@ Now let's run the application in test mode. sudo -E keploy test -c "python3 manage.py runserver" --delay 10 ``` -So no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres 😄** - -# Using Docker - -Keploy can be used on Linux & Windows through Docker, and on MacOS by the help of [Colima](https://docs.keploy.io/docs/server/macos/installation/#using-colima) - -## Create Keploy Alias - -To establish a network for your application using Keploy on Docker, follow these steps. - -If you're using a docker-compose network, replace keploy-network with your app's `docker_compose_network_name` below. - -```shell -alias keploy='sudo docker run --pull always --name keploy-v2 -p 16789:16789 --privileged --pid=host -it -v "$(pwd)":/files -v /sys/fs/cgroup:/sys/fs/cgroup -v /sys/kernel/debug:/sys/kernel/debug -v /sys/fs/bpf:/sys/fs/bpf -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/keploy/keploy' -``` +So, no need to setup fake database/apis like Postgres or write mocks for them. Keploy automatically mocks them and, **The application thinks it's talking to Postgres 😄** diff --git a/django-postgres/django_postgres/application/views.py b/django-postgres/django_postgres/application/views.py index 6bea49c..2c1ff2b 100644 --- a/django-postgres/django_postgres/application/views.py +++ b/django-postgres/django_postgres/application/views.py @@ -38,13 +38,16 @@ def get_update_deleteUser(request, uuid: uuid4): return JsonResponse({"message": "User Deleted!!"}) except Exception as e: return JsonResponse({"message": str(e)[2:-2]}) - + + @api_view(["GET", "POST"]) def getAll_createUser(request): if request.method == "GET": try: data = UserSerializer(User.objects.all(), many=True) + if data.data == []: + return JsonResponse({"message": "No Users Found!!"}) return Response(data.data) except Exception as e: return JsonResponse({"message": str(e)})