Django cannot find an app with manage.py syncdb

3.4k Views Asked by At

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!

1

There are 1 best solutions below

3
On

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)

python manage.py startapp MainBlog MainBlog

The startapp command is documented on the django website. This creates a few files in your MainBlog folder to start you out:

MainBlog/
    __init__.py
    models.py
    tests.py
    views.py

2) Manually add an __init__.py file to your MainBlog directory

touch MainBlog/__init__.py