This repository contains a basic Django setup for applying CRUD (Create, Read, Update, Delete) operations in an API. It uses Django and Django Rest Framework to create a simple API for managing movies. Follow the instructions below to set up and run the project.
Before you begin, ensure you have the following requirements installed:
- Django
- Django Rest Framework
- Requests
You can install these dependencies by running:
pip install -r requirements.txt
- Clone this repository to your local machine:
git clone https://github.com/auscode/testdjango.git
- Navigate to the project directory:
cd testdjango
- Migrate the database:
python manage.py migrate
- Create a superuser for accessing the Django admin interface:
python manage.py createsuperuser
Follow the prompts to create a superuser account.
- Start the development server:
python manage.py runserver
The development server will be available at http://127.0.0.1:8000/
.
This project provides the following API endpoints for managing movies:
GET /movies/
: Retrieve a list of all movies.POST /movies/
: Create a new movie.GET /movies/{id}/
: Retrieve details of a specific movie.PUT /movies/{id}/
: Update details of a specific movie.DELETE /movies/{id}/
: Delete a specific movie.
You can use tools like curl
, Postman, or write your own client to interact with the API. Here is an example of creating a new movie using curl
:
curl -X POST -H "Content-Type: application/json" -d '{
"name": "URI",
"description": "A war-ridden movie"
}' http://127.0.0.1:8000/movies/
Feel free to modify and expand upon this basic setup to meet your specific requirements for CRUD operations in your Django API.
For any questions or issues, please create a GitHub issue in this repository. Happy coding!