On Monday, 15 August 2011 15:27:44 UTC+1, Thorsten wrote: > > Hello, > > I am wondering if it is possible to do math on fields inside a query > with using the django syntax for example like > > SELECT (buyout / quantity) as buyout_per_item > > Currently I am using raw queries, because i couldn't find anything > about such cases. > > Greetings,
You can use the `extra()` model manager method to include extra calculated fields in your queries. I would say though that if you're just doing simple calculations, you're not really gaining anything by doing them in the database. It's just as easy to create a model method that returns the calculated value, which you can call as necessary. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ON4AWP51xv0J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

