Export to GitHub

django-pyodbc - issue #79

admin access failure (TypeError: 'NoneType' object is unsubscriptable)


Posted on Apr 29, 2010 by Grumpy Dog

What steps will reproduce the problem? 1. Setup django-pyodbc against Django 1.2 2. Add the admin application on your default database with django-pyodbc 3. Connect to the admin

What is the expected output? What do you see instead? The admin should load but instead I see the error: TypeError: 'NoneType' object is unsubscriptable

The full traceback is in the the Django ticket below...

What version of the product are you using? On what operating system? r177 (patched with the patches from #73 and #76)

Please provide any additional information below. See the Django ticket: http://code.djangoproject.com/ticket/12634

Comment #1

Posted on Apr 29, 2010 by Grumpy Dog

Here's the most concise way to reproduce the bug from the Django shell (python manage.py runserver):

from django.contrib.sessions.models import Session slist = Session.objects.filter(session_key='123123123') slist.exists() Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 494, in exists return self.query.has_results(using=self.db) File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 411, in has_results return bool(compiler.execute_sql(SINGLE)) File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/compiler.py", line 733, in execute_sql return cursor.fetchone()[:-len(self.query.ordering_aliases)] TypeError: 'NoneType' object is unsubscriptable

It only causes a problem when you search for an item that does not exist. What it looks like is that django-pyodbc is setting the query objects ordering_aliases (compiler.py). None of the Django supported backends do this.

Comment #2

Posted on Apr 30, 2010 by Swift Panda

a workaround in r178.

Comment #3

Posted on Apr 30, 2010 by Grumpy Dog

Some more info here

http://code.djangoproject.com/ticket/12634

Comment #4

Posted on Apr 30, 2010 by Grumpy Dog

Thanks for the response. I have reverted all of my custom code and I am now running on a clean trunk checkout of django-pyodbc and so far everything appears to be running smoothly. I'll let you know if I run into any issues.

Still, while the workaround seems to work (I'd come up with more or less the same workaround), I'm not sure it should be the final answer. I think some of the ordering code should be cleaned out to be more in line with the other backends.

Comment #5

Posted on Mar 24, 2011 by Swift Panda

(No comment was entered for this change.)

Status: Verified

Labels:
Type-Defect Priority-Medium