[Answered ]-Django self.model.DoesNotExist

1👍

The UUID is not NULL, so user_id=None will not work, it is the string None, so you retrieve this with:

User.objects.get(user_id='None')

A UUID is on most databases just a CharField that stores the UUID as a string, so it will call str(…) on it, and apparently it did that on the None object.

0👍

from uuid import UUID

try:
    user_uuid = UUID("your_uuid_here")  # Replace "your_uuid_here" with the actual UUID
    user = User.objects.get(user_id=user_uuid)
except User.DoesNotExist:
    # Handle the case where the user doesn't exist
    user = None  # Or any other appropriate action

Leave a comment