On Wednesday, 14 May 2014 01:20:39 UTC+1, Anthony Hawkes wrote:
>
> Thanks for the answer! Do you think it would be practical to let the orm 
> generate the base query and then doing a replace on the column name? I was 
> thinking of this approach as a custom manager method to return a raw result.
>
> This would allow me the generate a case statement for the column and I 
> could dynamically create it.
>
> Ant
>
You're thinking of this in the wrong way. Do you really need this data to 
be generated by the database in the query? Once the original values are out 
of the db and made into Python objects, you've got a whole powerful 
object-orientated language available to you to do whatever transformations 
you need on the data, ie Python. And you needn't do it at a queryset level: 
each of the elements of the queryset is a model instance, and in the 
process of accessing any of the values of those instances you're 
necessarily interacting with the model object, so you can simply add 
instance methods and call those instead of the original attributes.
--
DR.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fb2374d5-c928-4322-a0f0-517c24586eb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to