Ciao Raffaele,
(una certezza la tua risposta *;-)
> "[2]
http://localhost:8088/api/users/" -X POST -v -d '{"username":
> "[3]
http://localhost:8088/api/users/7/" -X PUT -d
> '{"id":7,"password":"secretpwd","last_login":null,"is_superuser":false,
> "username":"nicolas","first_name":"","last_name":"","email":"","is_staf
> f":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:
> 00"}'
> {"id":7,"password":"secretpwd","last_login":null,"is_superuser":false,"
> username":"nicolas","first_name":"","last_name":"","email":"","is_staff
> ":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:0
> 0","height":null,"groups":[],"user_permissions":[]}
> $ curl -H "Content-Type: application/json"
> "[4]
http://localhost:8088/api/users/7/" -X POST -d
> '{"id":7,"password":"secretpwd","last_login":null,"is_superuser":false,
> "username":"nicolas","first_name":"","last_name":"","email":"","is_staf
> f":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:
> 00"}'
> {"detail":"Method \"POST\" not allowed."}
> $ curl -H "Content-Type: application/json"
> "[5]
http://localhost:8088/api/users/7/" -X PATCH -d
> '{"id":7,"password":"secretpwd","last_login":null,"is_superuser":false,
> "username":"nicolas","first_name":"","last_name":"","email":"","is_staf
> f":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:
> 00"}'
> {"id":7,"password":"secretpwd","last_login":null,"is_superuser":false,"
> username":"nicolas","first_name":"","last_name":"","email":"","is_staff
> ":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:0
> 0","height":null,"groups":[],"user_permissions":[]}
> $ curl -H "Content-Type: application/json"
> "[6]
http://localhost:8088/api/users/7/" -X GET
Sicuro. Ho tutto come te. Il fatto che è tu sia nella PATCH che nella
PUT metti tutti i dati, mentre io suppongo (supponevo?) che quello che
non passo sia preso per nullo in una PUT:
sandro@bluff:~$ curl -s -H "Content-Type: application/json" "
http://localhost:8000/api/user/3/" | python -m json.tool{
"height": "122",
"country_id": null,
"date_joined": "2018-11-11T23:13:40.458283",
"email": "",
"first_name": "",
"id": 3,
"is_active": true,
"is_staff": false,
"is_superuser": false,
"last_login": null,
"last_name": "",
"username": "nicolas"
}
sandro@bluff:~$ curl -s -H "Content-Type: application/json" "
http://localhost:8000/api/user/3/" -X PATCH -d '{"height":122}'| python -m json.tool
{
"height": "122",
"country_id": null,
"date_joined": "2018-11-11T23:13:40.458283",
"email": "",
"first_name": "",
"id": 3,
"is_active": true,
"is_staff": false,
"is_superuser": false,
"last_login": null,
"last_name": "",
"username": "nicolas"
}
Questa è la prova di quanto dicevo, da dimostrare che sia sbagliata...
nel payload NON INVIO il valore di height che è opzionale e questo non
viene toccato. Il comportamento quindi diviene il medesimo di PATCH...
sandro@bluff:~$ curl -s -H "Content-Type: application/json" "
http://localhost:8000/api/user/3/" -X PUT -d '{"password":"secretpwd","last_login":null,"is_superuser":false,"username":"nicolas","first_name":"","last_name":"","email":"","is_staff":false,"is_active":true,"date_joined":"2018-11-12T00:13:40.458283+01:00"}' | python -m json.tool
{
"height": "122",
"country_id": null,
"date_joined": "2018-11-11T23:13:40.458283",
"email": "",
"first_name": "",
"id": 3,
"is_active": true,
"is_staff": false,
"is_superuser": false,
"last_login": null,
"last_name": "",
"username": "nicolas"
}
sandro
*:-)