dj-rest-auth
dj-rest-auth copied to clipboard
Problem with update user model endpoint when using PUT method
I'm trying to use this package to implement authentication in my project. However, I'm facing a problem with /dj-rest-auth/user/
endpoint, and there is no enough documentation.
When I try to use this endpoint with PUT
method with first_name
and last_name
I get this error:
{
"username": [
"This field is required."
]
}
And when I add the username
I get this error
{
"username": [
"A user with that username already exists."
]
}
Can anyone tell me how can I fix this? Thank you in advance.
I would also love to know the answer to this! I think it's because PUT needs a username but to update you want to hit PATCH
I am seeing this same error even with PATCH any ideas? I only started seeing this when i moved from djangl-rest-auth to dj-rest-auth
I'm having the same issue. I'm using the (current) latest stable versions:
- dj-rest-auth: v2.2.3
- django-allauth: v0.47.0
Although I wasn't able to use the PUT /dj-rest-auth/user
endpoint (passing username
, first_name
, and last_name
), I was able to use the PATCH
endpoint while omitting the username
(passing only the first_name
and last_name
).
Same problem. Btw, there is no test for PUT method on user_details
endpoint, only GET and PATCH: https://github.com/iMerica/dj-rest-auth/blob/f5079fef6a953d1fcf658b627a08265a62454ac0/dj_rest_auth/tests/test_api.py#L409-L423
I've also encountered the same problem with PATCH /dj-rest-auth/user/
with contents of username
, first_name
, and last_name
. However, I was able to PATCH
the first_name
and last_name
without passing username
as @grimzy said.
Is there any further information or solution about this?
I guess this is because the pk is kinda related username cohesively. I had this problem and found a solution, which is ok as far.
use PUT when the username changes, also include the pk in payload. use PATCH when the username doesn't, and exclude pk and username in payload.
const result =
state.username === userStore.username
? await doPatchUserDetail(payloadPatch)
: await doPutUserDetail(payloadPut);
Hi there trying to update user details with no success, like
curl -X PATCH 127.0.0.1:8000/dj-rest-auth/user/ -H "Authorization: Token 8eaf1f90a6c71e4f3e8b441372f9c29d6b6ef98f" -d first_name="artemggg" -d last_name="artemggg"
and it returns always
{"pk":17,"email":"[email protected]","first_name":null,"last_name":null}%
also tryed PUT with same result can some one say what i do wrong please