﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28446	QuerySet.extra is required for using SQL functions in SELECT clause	Chuck Horowitz	nobody	"In this case, I have a table that is indexed and queried based on long integer IP addresses.  My QuerySet will ultimately be passed along to a serializer expecting an IPAddressField compatible item however, which must be a valid IPv4 string.  So I would like SQL that looks like:

{{{
SELECT INET_NTOA(iplong) AS ip, COUNT(*) AS count FROM ipTable  GROUP BY INET_NTOA(iplong) ORDER BY count DESC;
}}}

To do this with ORM and QuerySet.extra() looks like:

{{{
Model.extra(select={'ip': 'INET_NTOA(iplong)'}).values('ip').annotate(count=Count('*')).order_by('-count')
}}}

This is not a problem for my application, but I wanted to pass this along as requested in the documentation.  Additionally, perhaps there is a better/more idomatic way of doing this (not requiring QuerySet.extra()) that you might be able to point me towards.

Thanks for making a great framework!

Best,
Chuck"	Cleanup/optimization	closed	Database layer (models, ORM)	1.11	Normal	invalid	QuerySet.extra		Unreviewed	0	0	0	0	0	0
