Update Me
Update an existing user.
HTTP Request
PATCH/api/users/me/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO A 500 SERVER ERROR
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 user to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| first_name | String | No | First name of the user. |
| last_name | String | No | Last name of the user. |
| username | String | No | Username (unique). |
| mobile_number | String | No | Mobile phone number(unique). |
| String | No | Email address (unique). | |
| gender | String | No | Gender of the user.(`male`, `female`, `other`) |
| avatar | File | No | Avatar image file to upload. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.put(
6 'http://www.example.com/api/users/me/',
7 json={
8 'first_name': 'Alexandra',
9 'last_name': 'Thompson',
10 'username': 'alex_thompson',
11 'mobile_number': '+1-555-0124',
12 'email': 'alexandra.thompson@techcorp.com',
13 'gender': 'female',
14 'avatar': open('path/to/avatar.jpg', 'rb')
15 }
16)1curl "http://www.example.com/api/users/me/" -X PUT -H "Authorization: Token XXXXXXXXXXXXXXXXXXXXXX" -H "Content-Type: application/json" -d '{
2 "first_name": "Alexandra",
3 "last_name": "Thompson",
4 "username": "alex_thompson",
5 "mobile_number": "+1-555-0124",
6 "email": "alexandra.thompson@techcorp.com",
7 "gender": "female",
8 "avatar": open('path/to/avatar.jpg', 'rb')
9}'| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the user. |
| username | String | profile username(unique, nullable) |
| mobile_number | String | Mobile number of the user (unique, nullable) |
| String | Email address of the user (unique, nullable) | |
| avatar | String | URL to the user's avatar image(nullable) |
| first_name | String | First name of the user(nullable) |
| last_name | String | Last name of the user(nullable) |
| full_name | String | Full name (nullable). |
| gender | String | Gender of the user (Male, Female, Other) |
| is_profile_compeleted | Boolean | Defines if user profile information are complete |
| groups | Array | Array of group IDs the user belongs to. |
| last_login | String (ISO 8601) | Timestamp of the user's last login. |
| created_at | String (ISO 8601) | Timestamp when the user was created. |
Group Object Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique id of the group |
| name | String | Name of the group |
| notes | String | Description of the group |
| users_count | Integer | Current number of the users in the group |
| created_at | Datetime | Creation time of the group |
| updated_at | Datetime | Last updated time of the group |
Example Response
{
"id": 1,
"username": "BehroozGhorbani",
"mobile_number": "09308744204",
"email": "behrooz21@hotmail.com",
"avatar": "http://127.0.0.1:8000/media/users/avatars/photo22132188258.jpg",
"first_name": "بهروز",
"last_name": "قربانی",
"full_name": "بهروز قربانی",
"gender": "male",
"is_profile_completed": true,
"groups": [
{
"id": 1,
"name": "Administrators",
"notes": "All system administrators with full permissions",
"users_count": 1,
"created_at": "2025-11-22T13:07:28.186722Z",
"updated_at": "2025-11-22T13:07:28.186728Z"
}
],
"last_login": "2025-11-29T12:35:37.440928Z",
"created_at": "2025-11-22T13:15:20.827325Z"
}
Notes
- The
avatarfield must be a valid image file (e.g., JPG, PNG). - To remove the avatar, you should set the value to
null(avatar=null)