I've been following the official Django 1.3 tutorial on their website. My issue comes when I add my custom app (polls) to the INSTALLED_APPS
list in settings.py
like such:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
'polls',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
However, when I go back and look at the stack trace I get this:
mod_fcgid: stderr: TemplateSyntaxError: Caught ImportError while rendering: No module named polls
What am I doing wrong? Here is the entire stack trace:
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: Traceback (most recent call last):
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "build/bdist.linux-i686/egg/flup/server/fcgi_base.py", line 574, in run
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "build/bdist.linux-i686/egg/flup/server/fcgi_base.py", line 1159, in handler
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: response = self.get_response(request)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 169, in get_response
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return debug.technical_500_response(request, *exc_info)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/views/debug.py", line 59, in technical_500_response
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: html = reporter.get_traceback_html()
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/views/debug.py", line 151, in get_traceback_html
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return t.render(c)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/base.py", line 123, in render
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return self._render(context)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/base.py", line 117, in _render
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return self.nodelist.render(context)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/base.py", line 744, in render
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: bits.append(self.render_node(node, context))
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 73, in render_node
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: result = node.render(context)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/debug.py", line 90, in render
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: output = self.filter_expression.resolve(context)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/base.py", line 536, in resolve
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: new_obj = func(obj, *arg_vals)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/template/defaultfilters.py", line 695, in date
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return format(value, arg)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py", line 285, in format
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return df.format(format_string)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py", line 30, in format
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: pieces.append(force_unicode(getattr(self, piece)()))
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py", line 191, in r
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return self.format('D, j M Y H:i:s O')
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py", line 30, in format
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: pieces.append(force_unicode(getattr(self, piece)()))
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/encoding.py", line 71, in force_unicode
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: s = unicode(s)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 206, in __unicode_cast
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return self.__func(*self.__args, **self.__kw)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/translation/__init__.py", line 81, in ugettext
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return _trans.ugettext(message)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 286, in ugettext
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: return do_translate(message, 'ugettext')
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 276, in do_translate
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: _default = translation(settings.LANGUAGE_CODE)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 185, in translation
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: default_translation = _fetch(settings.LANGUAGE_CODE)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/translation/trans_real.py", line 162, in _fetch
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: app = import_module(appname)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: File "/usr/lib/python2.4/site-packages/django/utils/importlib.py", line 35, in import_module
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: __import__(name)
[Sat Aug 04 07:16:55 2012] [warn] [client 74.202.255.243] mod_fcgid: stderr: TemplateSyntaxError: Caught ImportError while rendering: No module named polls
Edit...here is my sys.path
:
/home/andydefo/andydeforest
/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg
/usr/lib/python2.4/site-packages/setuptools-0.6c12dev_r88846-py2.4.egg
/usr/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg
/usr/lib/python2.4/site-packages/pip-1.1-py2.4.egg
/usr/lib/python24.zip
/usr/lib/python2.4
/usr/lib/python2.4/plat-linux2
/usr/lib/python2.4/lib-tk
/usr/lib/python2.4/lib-dynload
/usr/lib/python2.4/site-packages
/usr/lib/python2.4/site-packages/Numeric
/usr/lib/python2.4/site-packages/gtk-2.0
And my urls.py
:
from django.conf.urls.defaults import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'andydeforest.views.home', name='home'),
# url(r'^andydeforest/', include('andydeforest.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
Had the same problem, solved it, try this in the settings.py:
from here: http://www.bluehostforum.com/showthread.php?21680-DJANGO-Can-t-import-own-module