Update Blog Post
Update an existing blog post.
HTTP Request
PATCH/api/blog/posts/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the blog post to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| title | String | No | Updated title of the blog post. |
| slug | String | No | Updated slug for the blog post (should be unique). |
| excerpt | String | No | Updated short summary or excerpt of the blog post. |
| body | String | No | Updated full content of the blog post. |
| author | Integer | No | ID of the author of the blog post. |
| featured_image | Integer | No | ID of the featured image for the blog post. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2response = requests.patch('http://www.example.com/api/blog/posts/1', json={
3 'title': 'Updated Blog Post Title',
4 'excerpt': 'This is an updated excerpt for the blog post.',
5 'body': 'This is the updated full content of the blog post.'
6}, headers={
7 'Authorization': 'Token <your_api_key>'
8})
9
10print(response.json())1curl -X PATCH "http://www.example.com/api/blog/posts/1" -H "Authorization: Token <your_api_key>" -d '{
2 "title": "Updated Blog Post Title",
3 "excerpt": "This is an updated excerpt for the blog post.",
4 "body": "This is the updated full content of the blog post."
5}'Status Codes
| Code | Description |
|---|---|
| 200 | Blog post updated successfully |
| 400 | Bad request — invalid input |
| 404 | Blog post not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the blog post |
| title | String | Title of the blog post |
| slug | String | Slug for the blog post |
| views | Integer | Number of views the blog post has received |
| human_readable_views | String | Human-readable format of the views (e.g., 1.2K) |
| excerpt | String | Short summary or excerpt of the blog post |
| truncated_excerpt | String | Truncated version of the excerpt (e.g., first 100 characters) |
| author_data | Object | Author details including `id`, `username`, and `full_name` |
| featured_image_data | Object | Featured image data including `id`, `type`, `name`, `size`, `human_readable_size`, `f`, `width`, `height`, and `mode` |
| body | String | Full content of the blog post |
| truncated_body | String | Truncated version of the body (e.g., first 200 characters) |
| created_at | String (ISO 8601) | Timestamp when the blog post was created |
| updated_at | String (ISO 8601) | Timestamp when the blog post was last updated |
Author Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the author |
| username | String | Username of the author |
| full_name | String | Full name of the author (first and last name combined) |
Featured Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the featured image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
- Set True value to is_published field to publish the blog post immediately after creation. By default, it is set to False, meaning the blog post will be created as a draft (for showing in shop).