This project is a simple Django-based API that allows for the management of drink entities. It supports operations to list all drinks, create a new drink, retrieve a single drink detail, update a drink, and delete a drink.
- Python 3.x
- Django
- Django REST Framework
- Clone the repository to your local machine.
- Navigate to the project directory.
- Install the required dependencies:
pip install django djangorestframework
- Run the migrations to create the database schema:
python manage.py migrate
- Start the Django development server:
python manage.py runserver
- GET
/drinks/
- Retrieves a list of all drinks.
- POST
/drinks/
- Creates a new drink with the provided name and description.
- GET
/drinks/<int:id>
- Retrieves the details of a specific drink by ID.
- PUT
/drinks/<int:id>
- Updates the name and/or description of a specific drink.
- DELETE
/drinks/<int:id>
- Deletes a specific drink.
To retrieve a list of all drinks:
import requests
response = requests.get('http://127.0.0.1:8000/drinks')
print(response.json())
- The project uses Django REST Framework's function-based views and decorators to define API endpoints.
- Ensure you have set up the correct database settings in your
settings.py
file before running migrations. - For simplicity, this project does not implement authentication or permissions. Consider adding these features for production use.
Feel free to fork the project, make changes, and submit pull requests to contribute to the development of this API.