rossp/django-helpdesk — Issue #109: Error: FieldError at /helpdesk/tickets/ Invalid order_by arguments: [u'--created']
Author: magicrebirth
Created: 2012-01-18 12:19:51+00:00
State: open

I ran into this error while trying to save a Query with options Sorting>Created (reverse) AND All Statused selected.

The query runs fine, but when trying to save it throws an error.

I found out that the error doesn't come up if I remove the 'reverse' option ..

cheers, mik

===========================

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/helpdesk/tickets/?saved_query=3&csrfmiddlewaretoken=a046944672e42cc50a4ee05dc50c55b7

Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.databrowse',
'django.contrib.admin',
'django.contrib.staticfiles',
'mptt',
'picklefield',
'django_extensions',
'bobapp',
'helpdesk']
Installed Middleware:
('django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware')

Traceback:
File "/Applications/djangostack-1.3-0/apps/django/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Applications/djangostack-1.3-0/apps/django/lib/python2.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/Users/mac/Dropbox/code/django/projects/bob_project1.3/src/bob/libs/helpdesk/views/staff.py" in ticket_list
656. ticket_qs = apply_query(Ticket.objects.select_related(), query_params)
File "/Users/mac/Dropbox/code/django/projects/bob_project1.3/src/bob/libs/helpdesk/lib.py" in apply_query
179. queryset = queryset.order_by(params['sorting'])
File "/Applications/djangostack-1.3-0/apps/django/lib/python2.6/site-packages/django/db/models/query.py" in order_by
656. obj.query.add_ordering(*field_names)
File "/Applications/djangostack-1.3-0/apps/django/lib/python2.6/site-packages/django/db/models/sql/query.py" in add_ordering
1595. raise FieldError('Invalid order_by arguments: %s' % errors)

Exception Type: FieldError at /helpdesk/tickets/
Exception Value: Invalid order_by arguments: [u'--created']