#28335: Add query expressions support for models meta ordering
-------------------------------------+-------------------------------------
Reporter: cypreess | Owner: nobody
Type: | Status: new
Uncategorized |
Component: | Version: 1.11
Uncategorized | Keywords: model ordering F
Severity: Normal | query expressions
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I am trying to use F() statement inside ordering in model:
{{{
class MyModel(models.Model):
owner = models.ForeignKey(settings.AUTH_USER_MODEL, blank=True,
null=True)
created = models.DateTimeField(db_index=True, auto_now_add=True)
class Meta:
ordering = (F('owner_id').asc(nulls_first=True), 'created')
}}}
and this causes an error when running manage.py:
{{{
[...]
File "/[...]/lib/python3.6/site-packages/django/db/models/base.py", line
1651, in <genexpr>
fields = ((f[1:] if f.startswith('-') else f) for f in fields)
AttributeError: 'OrderBy' object has no attribute 'startswith'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28335>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.5ce71f53f8d9b81fda82af5feecde706%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.