"SELECT field as x..." with Django ORM

django, orm

Solution

use extra()

Foo.objects.filter(cond=1).extra(select={'sth_shiny':'my_field'})

Then you could access `sth_shiny` attr of resulted Foo instances

Problem

Is it possible to use AS sql statement with Django ORM: `SELECT my_field AS something_shiny WHERE my_condition = 1` If it is possible then how?

Original source

Related problems