Skip to main content

Update Product Comment

Updates an existing product comment

HTTP Request

PATCH/api/products/comments/:id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with ProductCommentPermission or Admin
  • Permission Code: 1883
  • 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())

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
titlestringTitle of the product

Example Response

{
"id": 1,
"rating": 1,
"content": "this is some very long long looooooooooooooooooooooooooong comment content for testiiiiiiing purposes",
"is_anonymous": false,
"is_published": true,
"created_at": "2025-11-22T15:24:49.833816Z",
"updated_at": "2025-12-24T15:05:33.868597Z",
"user_data": {
"id": 2,
"username": "staffer",
"full_name": "عماد رخشانی",
"avatar": "http://127.0.0.1:8000/media/users/avatars/Fantasticheskie_kartinki_dlja_monitora_68_76.jpg"
},
"product_data": {
"id": 36,
"title": "ماوس لاجیتک MX Vertical"
},
"truncated_content": "this is some very long long loooooooooooooooooooo…"
}