getting 'NoneType' object is unsubscriptable errors

1,011 views
Skip to first unread message

saureen adani

unread,
Jun 1, 2011, 3:48:13 AM6/1/11
to django...@googlegroups.com

Hi,

I am getting the following errors on some of the web pages

-----------------------------------------------------------

'NoneType' object is unsubscriptable

Request Method: GET
Request URL: http://nerd.hoonur.com/mypage/4605f1e14430950e07b74b5374472f00
Exception Type: TypeError
Exception Value:

'NoneType' object is unsubscriptable

Exception Location:
/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/classifieds/views.py
in get_gadget_data, line 2570
Python Executable: /usr/bin/python
Python Version: 2.6.2
Python Path:
['/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/',
'/usr/local/lib/python2.6/dist-packages/pymongo-1.7-py2.6-linux-x86_64.egg',
'/usr/local/lib/python2.6/dist-packages/simplejson-2.1.1-py2.6.egg',
'/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL', '/var/lib/python-support/python2.6',
'/var/lib/python-support/python2.6/gtk-2.0',
'/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode',
'/usr/local/lib/python2.6/dist-packages',
path('/home/balaji/new-staging-setup/trunk/python_modules'),
path('/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/python_modules')]
Server time: Wed, 1 Jun 2011 12:51:55 +0530

-----------------------------------------------------------

I tried putting the code line where the error was occuring under
try-catch-exception but still the error exits.

What could be the reason for the above error and possible solution to get
rid of above error?

Help would be highly appreciated !
--
View this message in context: http://old.nabble.com/getting-%27NoneType%27-object-is-unsubscriptable-errors-tp31747339p31747339.html
Sent from the django-users mailing list archive at Nabble.com.

Daniel Roseman

unread,
Jun 1, 2011, 5:05:36 AM6/1/11
to django...@googlegroups.com
On Wednesday, 1 June 2011 08:48:13 UTC+1, saureen adani wrote:

Hi,

I am getting the following errors on some of the web pages

-----------------------------------------------------------

'NoneType' object is unsubscriptable

Request Method: GET
Request URL: http://nerd.hoonur.com/mypage/4605f1e14430950e07b74b5374472f00
Exception Type: TypeError
Exception Value:

'NoneType' object is unsubscriptable

Exception Location:
/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/classifieds/views.py
in get_gadget_data, line 2570 

<snip>


You didn't think it would be useful to show us some of the actual code?

Although to be honest, if your views.py is over 2570 lines long, you've got more problems than we can sort here.
--
DR. 

Tom Evans

unread,
Jun 1, 2011, 5:53:09 AM6/1/11
to django...@googlegroups.com
On Wed, Jun 1, 2011 at 8:48 AM, saureen adani <sauree...@yahoo.co.in> wrote:
>
> Hi,
>
> I am getting the following errors on some of the web pages
>
> 'NoneType' object is unsubscriptable

>
> Help would be highly appreciated !

This error occurs when you attempt to subscript a variable that is None.

IE:

>>> a=None
>>> a[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is unsubscriptable


Don't try to index into a list without verifying that it is a list.

Cheers

Tom

Reply all
Reply to author
Forward
0 new messages