Skip to main content

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

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the user to update

Request Body

FieldTypeRequiredDescription
first_nameStringNoFirst name of the user.
last_nameStringNoLast name of the user.
usernameStringNoUsername (unique).
mobile_numberStringNoMobile phone number(unique).
emailStringNoEmail address (unique).
genderStringNoGender of the user.(`male`, `female`, `other`)
avatarFileNoAvatar image file to upload.

Example Requests

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)
FieldTypeDescription
idIntegerUnique ID of the user.
usernameStringprofile username(unique, nullable)
mobile_numberStringMobile number of the user (unique, nullable)
emailStringEmail address of the user (unique, nullable)
avatarStringURL to the user's avatar image(nullable)
first_nameStringFirst name of the user(nullable)
last_nameStringLast name of the user(nullable)
full_nameStringFull name (nullable).
genderStringGender of the user (Male, Female, Other)
is_profile_compeletedBooleanDefines if user profile information are complete
groupsArrayArray of group IDs the user belongs to.
last_loginString (ISO 8601)Timestamp of the user's last login.
created_atString (ISO 8601)Timestamp when the user was created.

Group Object Fields

FieldTypeDescription
idIntegerUnique id of the group
nameStringName of the group
notesStringDescription of the group
users_countIntegerCurrent number of the users in the group
created_atDatetimeCreation time of the group
updated_atDatetimeLast 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 avatar field must be a valid image file (e.g., JPG, PNG).
    • To remove the avatar, you should set the value to null (avatar=null)