6👍
Actually, I have tried this in my machine with database PostGres and it works,
>>> user = User_Profile.objects.create()
>>> user
<User_Profile: User_Profile object>
>>> user.id
UUID('d92c2280-4682-42ea-86c3-a1ed993c0638')
#copied the string of uuid only.
>>> id = 'd92c2280-4682-42ea-86c3-a1ed993c0638'
>>> User_Profile.objects.get(id=id)
<User_Profile: User_Profile object>
>>> import uuid
#converted the string into UUID format
>>> id = uuid.UUID(id)
>>> id
UUID('d92c2280-4682-42ea-86c3-a1ed993c0638')
>>> User_Profile.objects.get(id=id)
<User_Profile: User_Profile object>
If the problem still persists, try deleting the database and migrations and recreate it. The problem you are facing is not related to the database, it maybe something in your configuration.
2👍
The field is a UUID so you should pass a UUID to query it. It is quite straight-forward if you see it:
import uuid
id = uuid.UUID('193b6acc-2b78-4ddc-9ef8-632cde33ef74')
user_profile = User_Profile.objects.get(id=id)
- Is django-channels suitable for real time game?
- Django SelectDateWidget to show month and year only
- How to connect PyCharm to a Heroku postgres database
0👍
i assume your using postgreSQL :
The Django docs say : When used on PostgreSQL, this stores in a uuid datatype, otherwise in a char(32).
- Django countries encoding is not giving correct name
- Determining Django Model Instance Types after a Query on a Base-class
Source:stackexchange.com