This project follows the official Django REST Framework (DRF) tutorial to learn and understand the basics of building APIs with Django.
- Python 3.9
- Django
- djangorestframework
- Clone the repository
git clone https://github.com/codegeek004/django_rest_framework
cd django_rest_framework
- Create a virtual environment and activate it
python3 -m venv venv
source venv/bin/activate # On Windows, use venv\Scripts\activate
- Install the dependencies
pip install -r requirements.txt
python manage.py runserver
By default, the server will start at http://127.0.0.1:8000
.
This project implements:
- Basic Django models.
- Serializers for transforming data into JSON.
- API views using Django REST Framework.
- URL routing for API endpoints.
- Browsable API interface provided by DRF.
GET /api/items/
: List all items.POST /api/items/
: Create a new item.GET /api/items/{id}/
: Retrieve a specific item.PUT /api/items/{id}/
: Update a specific item.DELETE /api/items/{id}/
: Delete a specific item.
You can test the API using tools like:
- Postman
curl
- Browsable API interface at
http://127.0.0.1:8000/api/
curl -X GET http://127.0.0.1:8000/api/items/
import requests
response = requests.get("http://127.0.0.1:8000/api/items/")
print(response.json())
- Replace
'127.0.0.1:8000'
with your actual API URL if different. - Ensure the server is running before sending requests.
This project is licensed under the MIT License.