Reputation: 627
I need something like this: How to generate a hash of the result set in Postgress?
Is it possible using django orm?
Does anyone have any reference?
Upvotes: 0
Views: 386
Reputation: 3588
In the case of Django's User model it will be like below:
from django.contrib.auth.models import User
from django.db.models import Concat, Func, CharField
User.objects.annotate(
hash=Func(
Concat('first_name', 'last_name', output_field=CharField()),
function='md5',
)
)
Upvotes: 1