﻿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
26257	Add support for expressions like (Lower('myfield'),) in model Meta.ordering	Mikhail Mezyakov	nobody	"Example model:

{{{
from django.db import models
from django.db.models.functions import Lower


class BaseModel(models.Model)
    name = models.CharField(max_length=255)
    value = models.CharField(max_length=100)

    class Meta:
        ordering = (Lower('value'),)
}}}

With this model `manage.py test` command is running OK, but Django produces this trace when running `manage.py runserver`:

{{{
Performing system checks...

Unhandled exception in thread started by <function wrapper at 0x7f9d9a339488>
Traceback (most recent call last):
  File ""/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py"", line 229, in wrapper
    fn(*args, **kwargs)
  File ""/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py"", line 114, in inner_run
    self.validate(display_num_errors=True)
  File ""/usr/local/lib/python2.7/dist-packages/django/core/management/base.py"", line 469, in validate
    return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
  File ""/usr/local/lib/python2.7/dist-packages/django/core/management/base.py"", line 482, in check
    include_deployment_checks=include_deployment_checks,
  File ""/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py"", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File ""/usr/local/lib/python2.7/dist-packages/django/core/checks/model_checks.py"", line 28, in check_all_models
    errors.extend(model.check(**kwargs))
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1216, in check
    errors.extend(cls._check_ordering())
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1571, in _check_ordering
    fields = {f for f in fields if f != 'pk'}
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1571, in <setcomp>
    fields = {f for f in fields if f != 'pk'}
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1567, in <genexpr>
    fields = (f for f in fields if '__' not in f)
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1562, in <genexpr>
    fields = (f for f in fields if                                                                                                                                                                                                                                             
  File ""/usr/local/lib/python2.7/dist-packages/django/db/models/base.py"", line 1560, in <genexpr>                                                                                                                                                                              
    fields = ((f[1:] if f.startswith('-') else f) for f in fields)                                                                                                                                                                                                             
AttributeError: 'Lower' object has no attribute 'startswith'
}}}
 "	New feature	closed	Database layer (models, ORM)	1.8	Normal	fixed	meta, ordering, lower		Accepted	1	1	0	0	0	0
