Skip to main content

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

ParameterTypeRequiredDescription
idintegerYesUnique ID of the product comment

Request Body

FieldTypeRequiredDescription
contentStringNoComment content (max 500 characters)
userIntegerNoUser ID who posted the comment
productIntegerNoProduct ID being commented on
ratingIntegerNoRating given (1-5)
is_anonymousBooleanNoWhether the comment is posted anonymously
is_publishedBooleanNoWhether the comment is published

Example Requests

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())

Status Codes

CodeDescription
200Product comment updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Product comment not found
500Internal server error

Response Fields

FieldTypeDescription
idintegerUnique ID of the comment
ratingintegerRating given (1-5: Worst, Bad, Average, Good, Best)
contentstringComment content (max 500 characters)
is_anonymousbooleanWhether the comment is posted anonymously
is_publishedbooleanWhether the comment is published
user_dataobjectUser details (read-only)
product_dataobjectProduct details (read-only)
truncated_contentstringShortened version of content
created_atstring (ISO 8601)Timestamp when comment was created
updated_atstring (ISO 8601)Timestamp when comment was last updated

User Data Structure

FieldTypeDescription
idintegerUnique ID of the user
usernamestringUsername of the user
full_namestringFull name of the user
avatarstringURL of the user avatar image

Product Data Structure

FieldTypeDescription
idintegerUnique ID of the product
namestringName 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")