Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23390

Python change UUID object to string representation list

$
0
0

When retrieving a queryset with values_list of PKs there are of type UUIDField Django gives you a list of UUIDField objects and NOT a list of string UUIDs.

For example, the following gives me a query set:

items = Item.objects.values_list('id', flat=True).filter()

Where the output of print(items) is:

[UUID('00c8aa9e-2f61-4bac-320c-ab26b8fb1de9')]

But I would like the list to be a string representation of of UUID's i.e.

 ['00c8aa9e-2f61-4bac-320c-ab26b8fb1de9']

I can do this with each object individual in a loop but I want to change the whole queryset. Is this possible?

I have tried:

print(str(items))

Viewing all articles
Browse latest Browse all 23390

Trending Articles