In postgresql, I am able to combine two columns into one into an array like so
SELECT id, ARRAY[address,zip] as address_array FROM user
Is there a way to do this using django’s orm? Why? I want to be able to transform it into a dict mapping like
users = dict(User.objects.values("id", "address").all())
Gives me a mapping of:
{
1: "Address 1",
2: "Address 2",
...
...
}
And ultimately I want:
{
1: ["Address 1", "Zip 1"],
2: ["Address 2", "Zip 2"],
}
I am looking for a solution using django’s orm, not python. I know I can do this by using python code after looping through the queryset.