I think it would be a simple addition, and I would be very happy.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_docs: => 0
* resolution: => worksforme
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
Django 1.7, due to be released soon, includes a new feature:
[https://docs.djangoproject.com/en/1.7/ref/models/lookups/ Custom lookups
and transforms].
This allows you to solve the problem yourself.
If this doesn't answer your needs, please bring them up on the
DevelopersMailingList.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:1>
Comment (by jarshwah):
I don't think custom lookups and transforms works for this use case. The
ticket reporter wants to include that information in the select list.
Transforms and Lookups are only really used in filter clauses at the
moment.
There is a PR that will allow this kind of functionality here:
https://github.com/django/django/pull/2496
And to implement the length function, you'd create an object such as:
{{{
class Length(Func):
function = 'LENGTH'
def as_mssql(self, compiler, query):
self.function = 'LEN'
return super(Length, self).as_sql(compiler, query)
MyModel.objects.annotate(length=Length('myfield'))
}}}
I'm reopening on the basis that lookups and transforms don't solve the
problem.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:2>
* status: closed => new
* version: 1.6 => master
* resolution: worksforme =>
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:3>
Comment (by aaugustin):
Josh, I gather from your comment that this is covered by #14030, isn't it?
If so, this ticket can be closed as a duplicate. If not, could you clarify
what needs to be done to close it?
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:4>
Comment (by jarshwah):
I can't seem to find a ticket requesting an implementation of custom
functions (other than extensions to .extra()). #14030 will allow this
feature request to be implemented, but the original scope of 14030 was to
allow F() objects to be composed with aggregates.
I think we should open a new ticket that defines a list of functions to be
implemented by django (pending #14030), and close off any related tickets
such as this one as duplicates/wontfixes. I'm happy to open that new
ticket, but will have to do so later in the day.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:5>
* cc: jarshwah (added)
Comment:
Josh, just wanted to remind you about following up on this if you can.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:6>
Comment (by jarshwah):
Thanks Tim. I've resumed the discussion on the mailing list here:
https://groups.google.com/forum/#!searchin/django-developers/functions
/django-developers/HggiPzwkono/dsnx3BuXpnkJ
Once we reach some sort of consensus or enough time passes without
response, I'll go ahead and create the ticket. I'll bookmark this so I
remember to come back to it.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:7>
* status: new => closed
* resolution: => duplicate
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:8>
Comment (by jarshwah):
#23753 will take over for this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:9>