Jump to content

Django ImportError

Hasufein

Hello Everyone,

 

So i'm fiddling around with learning some Django (1.6.5, and py 2.7.6), and have an issue with my templates(?)

 

so in the views.py file for the site, classes which represent simple 'pages' work fine it seems; like a basic 'hello this page is working' set up.

 

However things begin to get a bit strange when i try adding templates. So i created a new folder in the project directory called 'template', in which i've put my html file.

 

so my urls.py currently looks like this:

#####

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'profit.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url(r'^hello/$', 'engine.views.hello'), #engine is the app name
    url(r'^hello_template/$', 'template.hello_template'), #template is dir.
)

#####

 

 

MOST* of the time the /hello and /admin pages work.

 

so i try to change my settings.py file to include a 'TEMPLATE_DIR' location, so it knows where to look for a template; but i notice in the tutorial i'm following (presumably Django 1.3) that TEMPLATE_DIR is a pre-existing variable which has been specified in the settings.py file, whereas it doesn't exist in my settings.py file (i guess there have been some changes with Django 1.6)

 

so I added it myself.

 

Now when i try test things; this is where everything goes to pot.

 

Most often the 127.0.0.1:8000/hello page will work - 127.0.0.1:8000/admin or /hello_template/ will not work and present me the following error..

 

########

ImportError at /admin/

No module named template

Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.6.5 Exception Type: ImportError Exception Value:
No module named template
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 40 Python Executable: /usr/bin/python Python Version: 2.7.6

 

#########

I went and checked out the 'exception location' as described in the above error path, and found nothing that would indicate the problem lied therein...

 

anyone have any ideas regarding this issue? :(

 

Thanks in advance,

H.

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

I'm just starting Django myself but I run Python 3. I'm not sure if you have any large codebases in 2.7 but 3 is definitely worth a go if you're not yet entrenched.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×