[Solved]-Django.core.exceptions.ValidationError: ["'' is not a valid UUID."]

6👍

Your problem is that you are trying to access request.POST

shipID = request.POST.get('id',None)

on DELETE request

[21/Jun/2017 00:08:53] “DELETE /ships HTTP/1.1” 500 20510

You are checking permission on object then why you are not using has_object_permission? http://www.django-rest-framework.org/api-guide/permissions/#examples

Also in your traceback it clearly states that issue is your views.py

File “C:\Users\ptao\Desktop\ViaFleet\ViaDjango\First_REST_API\Ships\views.py”, line 110, in delete ship = Ship.objects.get(id=id)

We need to see your actual view code

4👍

You write

I have logged the uuid being passed in from the POST request and it is indeed a properly formatted uuid (see below)

and your uuid image has the required 32 digits. However, the line quoted in uuid.py throws that exception when the stripped string has other than 32 digits.

So something is wrong with the type of the id.

From https://docs.djangoproject.com/en/1.11/ref/models/fields/:

UUIDField¶

class UUIDField(**options)[source]¶

A field for storing universally unique identifiers. Uses Python’s UUID class. When used on PostgreSQL, this stores in a uuid datatype, otherwise in a char(32).

The error line is

ship = Ship.objects.get(id=shipID)

where shipID is a string. Should your line be

get(id=UUID(shipID))

?

👤mikep

Leave a comment