ImportError No module named blog
I am working on a django tutorial http://net.tutsplus.com/tutorials/python-tutorials/python-from-scratch-creating-a-dynamic-website/ . Following the directions in the template section, I added:
TEMPLATE_DIRS = (
"F:/firstblog/blog/templates",
What is the full path.
I am getting the following error output:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4.3
Exception Type: ImportError
Exception Value:
No module named blog
Exception Location: f:\python27\lib\site-packages\django\utils\importlib.py in import_module, line 35
Python Executable: f:\python27\python.exe
Python Version: 2.7.3
My installed apps:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
I would appreciate any advice on how to fix this,
Thank,
Bill
source to share
you should also take a look at the tutorial included in the django docs for parts that may not be covered in what you find.
you may need to modify settings.py
and add the app blog
in INSTALLED_APPS
for the solution ImportError
. This is described in the section on activating models in the tutorial.
EDIT: here's what you need for the solution ImportError
you had.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog', # <------ your app here.
...
}
source to share
Sounds like a simple import error. Perhaps because you haven't installed the blog app, check your settings.py, is it installed?
Another problem might just be the wrong import path like
from blog.models import Blog
In any case, it looks like you should continue reading the docs. I found this video very helpful http://hackedexistence.com/project-django.html
Also another note from your code above doesn't list full paths like this ...
TEMPLATE_DIRS = (
"F:/firstblog/blog/templates",
This can give you a lot of problems later on.
source to share
Forgetting the commas after each INSTALLED_APPS can also lead to a similar error. For example:
INSTALLED_APPS = (
'django.contrib.auth' <----------- No Comma!
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
(Can help a newbie like me there)
source to share