[Fixed]-Django tastypie patch gives me a "500" error

1👍

Your PUT body has:

{
  ...
  "user_type": "1",
  "gender": "2"
}

and your model fields:

gender = models.SmallIntegerField(blank=True,choices=GENDERA_TYPES,null=True)
user_type = models.SmallIntegerField(blank=False,choices=USER_TYPES,default=0)

so you must make the PUT/PATCH request with numbers too like you specified in the model

{
  ...
  "user_type": 1,
  "gender": 2
}

wich is valid in JSON.

Hope this helps.

Regards!

Leave a comment