django static annotation

Viewed 17275

I want to add a static value to the results of a database query using django (so not using 'raw' SQL)

For example, if I have an object Car with fields make, model, and color, then I want my results set with extra static value to look something like this:

make     model     color    sales
----     -----     -----    -----
nissan   bluebird  black    0
ford     fiesta    red      0
toyota   camry     green    0

I tried code like

cars= Car.objects.all().annotate(sales=0)

but got errors. What can I do?

Cheers, Dave

--Trindaz on Fedang #django

2 Answers
Related