A REST api made with Django Rest Framework in which you can practice the methods: GET, POST, PUT and DELETE, of a tasks list application. This API will be connected to the postgres database.
Table of Contents
This project is made with the intention of create a REST API to book rooms and events
- Add the list of requirements in a requirements.txt file
- Create a REST API with the methods: GET, POST, PUT and DELETE
- Test endpoints
Major technologies
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.
Django REST framework is a powerful and flexible toolkit for building Web APIs.
With their streamlined API client, you can quickly and easily send REST, SOAP, GraphQL, and GRPC requests directly within Insomnia. Link to visit insomnia website: - Link
Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster. Link to visit postman website: - Link
For this project you need to have the postgres database installed. If you have not installed it yet, you can create a dockerfile to run your database, you can work with its graphical interface or from the console, both ways will serve you. Let's create a database from the terminal:
- open a terminal and type the following code to install postgres
docker run --name events -p 5433:5432 -e POSTGRES_USER=postgresUser -e POSTGRES_PASSWORD=postgresPW -e POSTGRES_DB=events -d postgres
DATABASE_HOST=192.168.0.116
DATABASE_USER=postgresUser
DATABASE_PASSWORD=postgresPW
DATABASE_NAME=events
DATABASE_PORT=5433
-
Clone the repo
git clone git@github.com:aldomatus/django-rooms-project.git
-
If you want, you can use a Dockerfile to run the project 🐳 otherwise follow the steps from 3
docker build -t events_backend:latest .; docker run --rm -it --env-file=.env -v ${PWD}:/usr/src/app -p 8000:8000 --name events_backend events_backend:latest
-
inside our dir we create a virtual environment to have our libraries together.
3.1 To download the library that allows us to create virtual environments
sudo apt-get install python3-venv
3.2. Create the virtual environment
python3 -m venv env_dir
3.3. Activate the virtual environment we go to the created folder and inside the terminal we write:
source env_dir/bin/activate
-
Once the virtual environment is activated, we return to the folder where the requirements.txt file is and to install our libraries we must type the following line. (if you are using python 3 you only must type python3)
python -m pip install -r requirements.txt
-
we run the server with...
python manage.py runserver
-
If all goes well, our application should already be executing the manage.py file with python using the postgres database, now we just have to check by entering the following link in our browser:
http://localhost:8000/
-
You should have a response like this:
{ "message": "Welcome to my API" }
Inside the repository there is a file called api.postman collection.json with which the tests can be done towards the endpoints
For the construction of the database, the relationship entity model was made with which the relationships between each table were deduced.
- The business can create a room with M capacity
- POST
- Send the json through the url: http://127.0.0.1:8000/rooms/create/
Response example:{ "is_available": 1, "capacity_of_users": 10, "busy_places": 0 }
Status: 201 Created { "capacity_of_users": 10, "busy_places": 0, "is_available": true }
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Aldo Matus - Linkedin Facebook
Project Link: Repository