i am running Mac OS X 10.7 and I succesfully created a project in django by using django-admin.py startproject MyBlog. In this folder i have manage.py, another folder titled MyBlog and an app folder which i created called MainBlog.
I needed to add this module, and a taggit module to my settings.py folder so i did (probably incorrectly).
Here it is..
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',
'MainBlog.taggit',
'MainBlog',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
I have also tried
'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',
'MainBlog.taggit',
'MyBlog.MainBlog',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
Neither of these work. They all return this error...
Error: No module named MainBlog
Any help would be greatly appreiciated. Ive been struggling with this for hours!
The error you are receiving is because django doesn't recognize your app,
MainBlog
, as a python package.Django modules are simply Python packages. You need an
__init__.py
file inside your app directory (MainBlog
) to get django to recognize it. See What is __init__.py for?There are two ways to fix this.
1) Initialize your app with the django script (recommended)
The
startapp
command is documented on the django website. This creates a few files in yourMainBlog
folder to start you out:2) Manually add an
__init__.py
file to your MainBlog directory