Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: FieldError at /helpdesk/tickets/ Invalid order_by arguments: [u'--created'] #109

Closed
ghost opened this issue Jan 18, 2012 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 18, 2012

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

  1.                     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
  2.             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
  3. 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
  4.     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
  5.     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
  6.         raise FieldError('Invalid order_by arguments: %s' % errors)
    

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

ivgiuliani added a commit to ivgiuliani/django-helpdesk that referenced this issue Jan 18, 2012
Changing parameters in apply_query might yield an invalid state in later
code that assumes the query was not changed.
This patch avoids parameters modification and should fix the issue
reported in django-helpdesk#109
@ivgiuliani
Copy link
Contributor

Can you please try the pull request in #108 and see if it solves this issue for you?

@rossp rossp closed this as completed Jan 23, 2012
@ghost
Copy link
Author

ghost commented Jan 31, 2012

[sorry for taking ages to do this]
I tried upgrading the libs.py and views/staff.py files, as in the patch. The error is fixed, but the search panel wont' work anymore.. all searches are ordered by 'date' irrespectively of what gets selected.
Maybe it's an error on my side (I'm on using git so I haven't updated properly) .. I'll do more tests.
tx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants