Forums

django 1.3 tutorial enabling admin throws Unhandled Exception

Hi I'm new to django and I.ve been following the https://docs.djangoproject.com/en/1.3/intro/tutorial02/ tutorial. As soon as I enable the admins by uncommenting the 3 lines highlighted, I get an unhandled exception on the site. Been through it now 5 times. When I re-comment problem goes away.

Bottom of the error log is 2014-04-06 12:12:49,951 : return do_translate(message, 'ugettext') 2014-04-06 12:12:49,951 : File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate 2014-04-06 12:12:49,951 : _default = translation(settings.LANGUAGE_CODE) 2014-04-06 12:12:49,951 : File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 185, in translation 2014-04-06 12:12:49,951 : default_translation = _fetch(settings.LANGUAGE_CODE) 2014-04-06 12:12:49,951 : File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 162, in _fetch 2014-04-06 12:12:49,951 : app = import_module(appname) 2014-04-06 12:12:49,952 : File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module 2014-04-06 12:12:49,952 : import(name) 2014-04-06 12:12:49,952 :django.template.base.TemplateSyntaxError: Caught ImportError while rendering: No module named polls

full version is kkscomputing.pythonanywhere.com.error.log

All seems absolutely fine. There was some mention of setting a pythonpath variable but I don't know enough to know where this is. Any help most welcome. kkscomputing.pythonanywhere.com is the site

Following the tutorial line by line: all the files/directories appear as should be.

I'm stumped! Any help possible??

Many thanks in anticipation

Our proxy server had a nervous breakdown. It's feeling better now.

Hi Thanks for the reply. Is it still unwell because I'm now getting a page can not be found error??

Thanks for the help

Nope, it's fine now. Exactly what is this new error?

Hi Harry I'm using https://docs.djangoproject.com/en/1.3/intro/tutorial02/ actually the same issue happened when I did the python3/django16 version

All is great up to the point, on page 2, where the admin site is enabled. There are 3 lines in the url.py file to change simply by un-commenting the code. At this point, it throws an unhandled exception error on the site. Is there something else I have to do to be able to see the django admin? I currently have my site looking at a mysql db which appears to work when python manage.py syncdb is called on bash.The processes in the tutorial have written to my mysql. I am following the tutorial and everything works perfectly apart from the admin side. I enabled the posts and used python manage.py startapp posts which also appeared to work perfectly

site is kkscomputing.pythonanywhere.com. I'll recreate the error now.

Any help most gratefully received

thanks Steve

Is there anything of use in your error logs?

Hi Harry

its a bit long but below is the last trace. If there is anything in this, I don't follow. Thanks Steve

2014-04-07 06:34:49,969 :Traceback (most recent call last):
2014-04-07 06:34:49,972 :  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
2014-04-07 06:34:49,972 :    self.error_log_file.logger.exception("Error running WSGI application")
2014-04-07 06:34:49,972 :  File "/usr/lib/python2.7/logging/__init__.py", line 1183, in exception
2014-04-07 06:34:49,974 :    self.error(msg, *args, **kwargs)
2014-04-07 06:34:49,975 :  File "/usr/lib/python2.7/logging/__init__.py", line 1176, in error
2014-04-07 06:34:49,975 :    self._log(ERROR, msg, args, **kwargs)
2014-04-07 06:34:49,975 :  File "/usr/lib/python2.7/logging/__init__.py", line 1268, in _log
2014-04-07 06:34:49,975 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2014-04-07 06:34:49,975 :  File "/usr/lib/python2.7/logging/__init__.py", line 1242, in makeRecord
2014-04-07 06:34:49,976 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2014-04-07 06:34:49,976 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2014-04-07 06:34:49,976 :    self.threadName = threading.current_thread().name
2014-04-07 06:34:49,976 :  File "/usr/lib/python2.7/threading.py", line 1158, in currentThread
2014-04-07 06:34:49,978 :    return _active[_get_ident()]
2014-04-07 06:34:49,978 :  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
2014-04-07 06:34:49,978 :    app_iterator = self.app(environ, start_response)
2014-04-07 06:34:49,978 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
2014-04-07 06:34:49,979 :    response = self.get_response(request)
2014-04-07 06:34:49,979 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
2014-04-07 06:34:49,979 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2014-04-07 06:34:49,979 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
2014-04-07 06:34:49,980 :    return debug.technical_500_response(request, *exc_info)
2014-04-07 06:34:49,980 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 59, in technical_500_response
2014-04-07 06:34:49,981 :    html = reporter.get_traceback_html()
2014-04-07 06:34:49,981 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 151, in get_traceback_html
2014-04-07 06:34:49,981 :    return t.render(c)
2014-04-07 06:34:49,981 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 123, in render
2014-04-07 06:34:49,982 :    return self._render(context)
2014-04-07 06:34:49,983 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
2014-04-07 06:34:49,983 :    return self.nodelist.render(context)
2014-04-07 06:34:49,983 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
2014-04-07 06:34:49,984 :    bits.append(self.render_node(node, context))
2014-04-07 06:34:49,984 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 73, in render_node
2014-04-07 06:34:49,985 :    result = node.render(context)
2014-04-07 06:34:49,986 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
2014-04-07 06:34:49,986 :    output = self.filter_expression.resolve(context)
2014-04-07 06:34:49,986 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 536, in resolve
2014-04-07 06:34:49,986 :    new_obj = func(obj, *arg_vals)
2014-04-07 06:34:49,986 :  File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 695, in date
2014-04-07 06:34:49,989 :    return format(value, arg)
2014-04-07 06:34:49,989 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 285, in format
2014-04-07 06:34:49,993 :    return df.format(format_string)
2014-04-07 06:34:49,993 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:49,993 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:49,993 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 191, in r
2014-04-07 06:34:49,993 :    return self.format('D, j M Y H:i:s O')
2014-04-07 06:34:49,993 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:49,993 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:49,994 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 71, in force_unicode
2014-04-07 06:34:49,994 :    s = unicode(s)
2014-04-07 06:34:49,995 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 206, in __unicode_cast
2014-04-07 06:34:49,996 :    return self.__func(*self.__args, **self.__kw)
2014-04-07 06:34:49,996 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 81, in ugettext
2014-04-07 06:34:50,011 :    return _trans.ugettext(message)
2014-04-07 06:34:50,011 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 286, in ugettext
2014-04-07 06:34:50,012 :    return do_translate(message, 'ugettext')
2014-04-07 06:34:50,012 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate
2014-04-07 06:34:50,012 :    _default = translation(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,012 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 185, in translation
2014-04-07 06:34:50,013 :    default_translation = _fetch(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,013 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 162, in _fetch
2014-04-07 06:34:50,013 :    app = import_module(appname)
2014-04-07 06:34:50,013 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
2014-04-07 06:34:50,013 :    __import__(name)
2014-04-07 06:34:50,013 :django.template.base.TemplateSyntaxError: Caught ImportError while rendering: No module named polls
2014-04-07 06:34:50,522 :Traceback (most recent call last):
2014-04-07 06:34:50,522 :  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
2014-04-07 06:34:50,522 :    self.error_log_file.logger.exception("Error running WSGI application")
2014-04-07 06:34:50,522 :  File "/usr/lib/python2.7/logging/__init__.py", line 1183, in exception
2014-04-07 06:34:50,523 :    self.error(msg, *args, **kwargs)
2014-04-07 06:34:50,523 :  File "/usr/lib/python2.7/logging/__init__.py", line 1176, in error
2014-04-07 06:34:50,523 :    self._log(ERROR, msg, args, **kwargs)
2014-04-07 06:34:50,523 :  File "/usr/lib/python2.7/logging/__init__.py", line 1268, in _log
2014-04-07 06:34:50,523 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2014-04-07 06:34:50,524 :  File "/usr/lib/python2.7/logging/__init__.py", line 1242, in makeRecord
2014-04-07 06:34:50,524 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2014-04-07 06:34:50,524 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2014-04-07 06:34:50,524 :    self.threadName = threading.current_thread().name
2014-04-07 06:34:50,524 :  File "/usr/lib/python2.7/threading.py", line 1158, in currentThread
2014-04-07 06:34:50,525 :    return _active[_get_ident()]
2014-04-07 06:34:50,525 :  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
2014-04-07 06:34:50,525 :    app_iterator = self.app(environ, start_response)
2014-04-07 06:34:50,525 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
2014-04-07 06:34:50,525 :    response = self.get_response(request)
2014-04-07 06:34:50,525 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
2014-04-07 06:34:50,526 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2014-04-07 06:34:50,526 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
2014-04-07 06:34:50,526 :    return debug.technical_500_response(request, *exc_info)
2014-04-07 06:34:50,526 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 59, in technical_500_response
2014-04-07 06:34:50,526 :    html = reporter.get_traceback_html()
2014-04-07 06:34:50,526 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 151, in get_traceback_html
2014-04-07 06:34:50,526 :    return t.render(c)
2014-04-07 06:34:50,527 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 123, in render
2014-04-07 06:34:50,527 :    return self._render(context)
2014-04-07 06:34:50,527 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
2014-04-07 06:34:50,527 :    return self.nodelist.render(context)
2014-04-07 06:34:50,527 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
2014-04-07 06:34:50,527 :    bits.append(self.render_node(node, context))
2014-04-07 06:34:50,527 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 73, in render_node
2014-04-07 06:34:50,528 :    result = node.render(context)
2014-04-07 06:34:50,528 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
2014-04-07 06:34:50,528 :    output = self.filter_expression.resolve(context)
2014-04-07 06:34:50,528 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 536, in resolve
2014-04-07 06:34:50,528 :    new_obj = func(obj, *arg_vals)
2014-04-07 06:34:50,528 :  File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 695, in date
2014-04-07 06:34:50,529 :    return format(value, arg)
2014-04-07 06:34:50,529 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 285, in format
2014-04-07 06:34:50,529 :    return df.format(format_string)
2014-04-07 06:34:50,529 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:50,529 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:50,529 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 191, in r
2014-04-07 06:34:50,529 :    return self.format('D, j M Y H:i:s O')
2014-04-07 06:34:50,530 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:50,530 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:50,530 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 71, in force_unicode
2014-04-07 06:34:50,530 :    s = unicode(s)
2014-04-07 06:34:50,530 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 206, in __unicode_cast
2014-04-07 06:34:50,530 :    return self.__func(*self.__args, **self.__kw)
2014-04-07 06:34:50,530 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 81, in ugettext
2014-04-07 06:34:50,531 :    return _trans.ugettext(message)
2014-04-07 06:34:50,531 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 286, in ugettext
2014-04-07 06:34:50,531 :    return do_translate(message, 'ugettext')
2014-04-07 06:34:50,531 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate
2014-04-07 06:34:50,531 :    _default = translation(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,531 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 185, in translation
2014-04-07 06:34:50,531 :    default_translation = _fetch(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,532 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 162, in _fetch
2014-04-07 06:34:50,532 :    app = import_module(appname)
2014-04-07 06:34:50,532 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
2014-04-07 06:34:50,532 :    __import__(name)
2014-04-07 06:34:50,532 :django.template.base.TemplateSyntaxError: Caught ImportError while rendering: No module named polls
2014-04-07 06:34:50,692 :Traceback (most recent call last):
2014-04-07 06:34:50,692 :  File "/bin/user_wsgi_wrapper.py", line 67, in __call__
2014-04-07 06:34:50,693 :    self.error_log_file.logger.exception("Error running WSGI application")
2014-04-07 06:34:50,693 :  File "/usr/lib/python2.7/logging/__init__.py", line 1183, in exception
2014-04-07 06:34:50,693 :    self.error(msg, *args, **kwargs)
2014-04-07 06:34:50,693 :  File "/usr/lib/python2.7/logging/__init__.py", line 1176, in error
2014-04-07 06:34:50,694 :    self._log(ERROR, msg, args, **kwargs)
2014-04-07 06:34:50,694 :  File "/usr/lib/python2.7/logging/__init__.py", line 1268, in _log
2014-04-07 06:34:50,694 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2014-04-07 06:34:50,694 :  File "/usr/lib/python2.7/logging/__init__.py", line 1242, in makeRecord
2014-04-07 06:34:50,695 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2014-04-07 06:34:50,695 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2014-04-07 06:34:50,701 :    self.threadName = threading.current_thread().name
2014-04-07 06:34:50,702 :  File "/usr/lib/python2.7/threading.py", line 1158, in currentThread
2014-04-07 06:34:50,702 :    return _active[_get_ident()]
2014-04-07 06:34:50,702 :  File "/bin/user_wsgi_wrapper.py", line 59, in __call__
2014-04-07 06:34:50,702 :    app_iterator = self.app(environ, start_response)
2014-04-07 06:34:50,702 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
2014-04-07 06:34:50,702 :    response = self.get_response(request)
2014-04-07 06:34:50,703 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
2014-04-07 06:34:50,703 :    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2014-04-07 06:34:50,703 :  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
2014-04-07 06:34:50,703 :    return debug.technical_500_response(request, *exc_info)
2014-04-07 06:34:50,703 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 59, in technical_500_response
2014-04-07 06:34:50,703 :    html = reporter.get_traceback_html()
2014-04-07 06:34:50,703 :  File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 151, in get_traceback_html
2014-04-07 06:34:50,704 :    return t.render(c)
2014-04-07 06:34:50,704 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 123, in render
2014-04-07 06:34:50,704 :    return self._render(context)
2014-04-07 06:34:50,704 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 117, in _render
2014-04-07 06:34:50,704 :    return self.nodelist.render(context)
2014-04-07 06:34:50,704 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 744, in render
2014-04-07 06:34:50,704 :    bits.append(self.render_node(node, context))
2014-04-07 06:34:50,705 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 73, in render_node
2014-04-07 06:34:50,705 :    result = node.render(context)
2014-04-07 06:34:50,705 :  File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
2014-04-07 06:34:50,705 :    output = self.filter_expression.resolve(context)
2014-04-07 06:34:50,705 :  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 536, in resolve
2014-04-07 06:34:50,705 :    new_obj = func(obj, *arg_vals)
2014-04-07 06:34:50,709 :  File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 695, in date
2014-04-07 06:34:50,709 :    return format(value, arg)
2014-04-07 06:34:50,709 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 285, in format
2014-04-07 06:34:50,709 :    return df.format(format_string)
2014-04-07 06:34:50,709 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:50,709 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:50,710 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 191, in r
2014-04-07 06:34:50,710 :    return self.format('D, j M Y H:i:s O')
2014-04-07 06:34:50,710 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 30, in format
2014-04-07 06:34:50,710 :    pieces.append(force_unicode(getattr(self, piece)()))
2014-04-07 06:34:50,710 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 71, in force_unicode
2014-04-07 06:34:50,710 :    s = unicode(s)
2014-04-07 06:34:50,710 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 206, in __unicode_cast
2014-04-07 06:34:50,710 :    return self.__func(*self.__args, **self.__kw)
2014-04-07 06:34:50,711 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 81, in ugettext
2014-04-07 06:34:50,711 :    return _trans.ugettext(message)
2014-04-07 06:34:50,711 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 286, in ugettext
2014-04-07 06:34:50,711 :    return do_translate(message, 'ugettext')
2014-04-07 06:34:50,711 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate
2014-04-07 06:34:50,711 :    _default = translation(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,711 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 185, in translation
2014-04-07 06:34:50,712 :    default_translation = _fetch(settings.LANGUAGE_CODE)
2014-04-07 06:34:50,712 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 162, in _fetch
2014-04-07 06:34:50,712 :    app = import_module(appname)
2014-04-07 06:34:50,712 :  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
2014-04-07 06:34:50,712 :    __import__(name)
2014-04-07 06:34:50,712 :django.template.base.TemplateSyntaxError: Caught ImportError while rendering: No module named polls

I think the "No module named polls" is the hint. It looks like you're trying to import an app called polls, but it's not available. Any idea what might be happening there?