This Django REST Framework project provides a simple blogging API to manage blog posts. It supports full CRUD operations: Create, Read, Update, Delete, and includes filtering posts by title.
- Django
- Django REST Framework (DRF)
- SQLite (default development database)
| Field | Type | Description |
|---|---|---|
id |
AutoField |
Primary key (auto-generated) |
title |
CharField |
Title of the blog post (max 100) |
content |
TextField |
Main content of the blog post |
published_date |
DateTimeField |
Timestamp of creation (auto-added) |
Serializes and deserializes BlogPost data.
{
"id": 1,
"title": "My First Blog",
"content": "This is the content...",
"published_date": "2025-04-18T12:34:56Z"
}- Description: Retrieve a list of all blog posts.
- Response: 200 OK + list of serialized blog posts.
- Description: Create a new blog post.
- Body Example:
{
"title": "New Post",
"content": "Some interesting content."
}- Response: 201 Created + created blog post.
- Description: Delete all blog posts.
- Response: 204 No Content
⚠️ This deletes all blog posts. Use with caution.
- Description: Retrieve a single blog post by ID.
- Response: 200 OK + blog post data
- 404: If blog post is not found.
- Description: Update an entire blog post.
- Response: 200 OK + updated post
- Description: Partially update a blog post.
- Response: 200 OK + updated post
- Description: Delete a blog post by ID.
- Response: 204 No Content
- Description: Filter blog posts by partial match in title.
- Query Param:
title(optional) - Example:
/filter-blogposts/?title=django - Response: 200 OK + filtered blog posts
python manage.py makemigrations
python manage.py migrate
python manage.py runserverYou can test the API with:
- Postman
- cURL
- DRF's browsable API
Let me know if you want this turned into a Swagger/OpenAPI spec, a Markdown file, or automated tests using Django's test client!