How change returned value after annotation queryset of model?

25 views
Skip to first unread message

Seti Volkylany

unread,
Jun 16, 2016, 5:51:51 AM6/16/16
to Django users
If I used annotation for get rating an object, I had new field 'rating' (is number). How change values field rating through SQl for return:
if rating = 0 return '0'
if rating = 1 return '+1'
if rating = -1 return '-1'

Jani Tiainen

unread,
Jun 16, 2016, 6:47:56 AM6/16/16
to django...@googlegroups.com
On option could be using choices on a field definition.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16b9bdbc-a292-4162-9809-59a55d63ff34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Jani Tiainen
Reply all
Reply to author
Forward
0 new messages