First time here? Check out the FAQ!

AttributeError: 'NoneType' object has no attribute 'get_absolute_url'

Hello again!

Next error shows every time when I try to view my Inbox (http://localhost/users/1/support/?sort=inbox&section=forum)

Traceback (most recent call last):

 File "/var/src/askbot-devel/askbot_env/lib/python2.6/site-packages/django/core/handlers/", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/var/src/askbot-devel/askbot/views/", line 824, in user
   return user_view_func(request, profile_owner, context)

 File "/var/src/askbot-devel/askbot/views/", line 55, in wrapped_func
   return f(request, profile_owner, context)

 File "/var/src/askbot-devel/askbot/views/", line 602, in user_responses
   'response_url': memo.activity.get_absolute_url(),

 File "/var/src/askbot-devel/askbot_env/lib/python2.6/site-packages/django/utils/", line 55, in _curried
   return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))

 File "/var/src/askbot-devel/askbot_env/lib/python2.6/site-packages/django/db/models/", line 887, in get_absolute_url
   return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs)

 File "/var/src/askbot-devel/askbot/models/", line 209, in get_absolute_url
   return self.content_object.get_absolute_url()

AttributeError: 'NoneType' object has no attribute 'get_absolute_url'

GET:<QueryDict: {u'sort': [u'inbox'], u'section': [u'forum']}>,
POST:<QueryDict: {}>,
COOKIES:{'askbot_visitor': 'False',
 'help.sunline.ua_csrf': '62dd351bd315bb8e3bc556353e995e62',
 'help_csrf': '70f00bfa211d743a9b34d112c214d483',
 'sessionid': '68c54d825d903f9aa423b25079b18b18'},
META:{'DOCUMENT_ROOT': '/var/www/localhost',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'ru-RU,ru,en-US;q=0.9,en;q=0.9,en-gb;q=0.9,bg-BG;q=0.9,bg;q=0.8,uk-UA;q=0.8,uk;q=0.8,nl-NL;q=0.7,nl;q=0.7,de-DE;q=0.7,de;q=0.7,fr-FR;q=0.6,fr;q=0.6,es-ES;q=0.6,es;q=0.5,ar-AE;q=0.5,ar;q=0.5,zh-CN;q=0.5,zh;q=0.4,th-TH;q=0.4,th;q=0.4,ru-RU-lite;q=0.3,ja-JP;q=0.3,ja;q=0.3,pt-PT;q=0.3,pt;q=0.2,en-EN;q=0.2,eo-EO;q=0.2,eo;q=0.1,pt-BR;q=0.1,ru-x-mtfrom-et;q=0.1,vi-VN;q=0.1,vi;q=0.0',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'localhost_csrf=62dd351bd315bb8e3bc556353e995e62; sessionid=68c54d825d903f9aa423b25079b18b18; help_csrf=70f00bfa211d743a9b34d112c214d483; askbot_visitor=False',
 'HTTP_HOST': 'localhost',
 'HTTP_REFERER': 'http://localhost/questions/',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/15.0 Firefox/15.0a1',
 'PATH_INFO': u'/users/1/support/',
 'PATH_TRANSLATED': '/var/www/localhost/django.wsgi/users/1/support/',
 'QUERY_STRING': 'sort=inbox&section=forum',
 'REMOTE_PORT': '59932',
 'REQUEST_URI': '/users/1/support/?sort=inbox&section=forum',
 'SCRIPT_FILENAME': '/var/www/localhost/django.wsgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADMIN': 'support@slocalhost',
 'SERVER_NAME': 'localhost',
 'SERVER_PORT': '80',
 'SERVER_SIGNATURE': '<address>Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze8 with Suhosin-Patch mod_wsgi/3.3 Python/2.6.6 mod_perl/2.0.4 Perl/v5.10.1 Server at localhost Port 80</address>\n',
 'SERVER_SOFTWARE': 'Apache/2.2.16 (Debian ...
Olloff's avatar
asked 2012-05-12 00:54:15 -0500, updated 2012-05-16 01:10:55 -0500
edit flag offensive 0 remove flag close merge delete



This bug is fixed in the development branch. I hope to release in two days.

Evgeny's avatar Evgeny (2012-05-12 13:58:56 -0500) edit

Thanks, Evgeny.

Olloff's avatar Olloff (2012-05-14 00:12:52 -0500) edit

@Evgeny, sorry for my importunity, but is this bug fixed by recent commits? I still receive these messages.

Olloff's avatar Olloff (2012-05-15 07:58:05 -0500) edit

Did you try yesterday's release? If so, I would need more details about that Activity record - activity_type and other values. Perhaps you could identify the id of that record and then type in the database console: SELECT * FROM activity WHERE id=[record_id] (without the brackets) and post the output here.

Evgeny's avatar Evgeny (2012-05-15 10:31:59 -0500) edit

Yes, I already use most recent build. How can I find broken record? I tried to check every activity record for few users (both from mysql console and from livesettings) and all records seems readable. Edit: I've added grouped listing of activity_type to question

Olloff's avatar Olloff (2012-05-16 01:05:14 -0500) edit
add a comment see more comments

1 Answer


Problem related to incorrect activity records - some object_id in column 'activity' was filled with nonexistent objects. Probably this happened when I restored site from backup after crush. I was need to execute next query to find broken ids:

SELECT as aid FROM activity LEFT JOIN askbot_post ON WHERE IS NULL;
Olloff's avatar
answered 2012-05-28 03:01:11 -0500
edit flag offensive 0 remove flag delete link



Right, this has to do with objects with id == activity.object_id do not exist when they are deleted, but activity records stay. It is not because your database was restored, it is a bug in the code.

Evgeny's avatar Evgeny (2012-05-28 03:06:50 -0500) edit

It looks like the issue is due to deleted comments. In the past comments did not have revisions in the database, now they do, but still - we delete them the "hard" way - just delete the objects. Questions and answers are deleted the "soft" way - by setting post.deleted = True.

Evgeny's avatar Evgeny (2012-05-29 03:35:56 -0500) edit
add a comment see more comments