Update Product Comment
Updates an existing product comment's information.
HTTP Request
PATCH/api/products/comments/: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 product comment |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| content | String | No | Comment content (max 500 characters) |
| user | Integer | No | User ID who posted the comment |
| product | Integer | No | Product ID being commented on |
| rating | Integer | No | Rating given (1-5) |
| is_anonymous | Boolean | No | Whether the comment is posted anonymously |
| is_published | Boolean | No | Whether the comment is published |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Partial update (PATCH)
4response = requests.patch('http://www.example.com/api/products/comments/123',
5 json={
6 'content': 'Updated comment: This product exceeded my expectations!',
7 'rating': 5,
8 'is_published': True
9 },
10 headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update publication status
15response = requests.patch('http://www.example.com/api/products/comments/123',
16 json={
17 'is_published': False,
18 'is_anonymous': True
19 },
20 headers={'Authorization': 'Token <your_api_key>'}
21)
22print(response.json())1# Partial update (PATCH)
2curl -X PATCH "http://www.example.com/api/products/comments/123" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
6 "content": "Updated comment: This product exceeded my expectations!",
7 "rating": 5,
8 "is_published": true
9}'
10
11# Update publication status
12curl -X PATCH "http://www.example.com/api/products/comments/123" \
13-H "Authorization: Token <your_api_key>" \
14-H "Content-Type: application/json" \
15-d '{
16 "is_published": false,
17 "is_anonymous": true
18}'Status Codes
| Code | Description |
|---|---|
| 200 | Product comment updated successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Product comment not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique ID of the comment |
| rating | integer | Rating given (1-5: Worst, Bad, Average, Good, Best) |
| content | string | Comment content (max 500 characters) |
| is_anonymous | boolean | Whether the comment is posted anonymously |
| is_published | boolean | Whether the comment is published |
| user_data | object | User details (read-only) |
| product_data | object | Product details (read-only) |
| truncated_content | string | Shortened version of content |
| created_at | string (ISO 8601) | Timestamp when comment was created |
| updated_at | string (ISO 8601) | Timestamp when comment was last updated |
User Data Structure
| Field | Type | Description |
|---|---|---|
| id | integer | Unique ID of the user |
| username | string | Username of the user |
| full_name | string | Full name of the user |
| avatar | string | URL of the user avatar image |
Product Data Structure
| Field | Type | Description |
|---|---|---|
| id | integer | Unique ID of the product |
| name | string | Name of the product |
Notes
- Use PATCH for partial updates - only include fields you want to change
- Changing publication status affects comment visibility to public users
- Rating updates will affect the overall product rating calculation
- All timestamps are in ISO 8601 format (e.g., "2023-01-01T12:00:00Z")