0

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!

user1074202
  • 139
  • 1
  • 4
  • 14
  • 1
    Does MainBlog.taggit throw an error as well? Usually I just add `appName` to INSTALLED_APPS and it works. Did you try just `'MyBlog'` – Benoir Aug 02 '12 at 20:23
  • How did you create your app? Did you run `python manage.py startapp MainBlog`, or did you simply create the `MainBlog` folder? – Cypress Frankenfeld Aug 02 '12 at 20:39

1 Answers1

2

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
Community
  • 1
  • 1
Cypress Frankenfeld
  • 2,317
  • 2
  • 28
  • 40
  • Awesome! Thank you so much this worked. Altough now it is raising the error, no module named taggit. Do i need to put another init.py file in the django-taggit folder on maybe the MyBlog one? THanks in advance! – user1074202 Aug 03 '12 at 03:29
  • Make sure you are following the django-tagg itinstallation instructions: http://django-taggit.readthedocs.org/en/latest/getting_started.html `pip install django-taggit` Then add `'taggit'` to your `INSTALLED_APPS` setting. – Cypress Frankenfeld Aug 03 '12 at 14:39
  • Hmm. for some reason it is still not finding it. I installed it correctly and i have it as 'taggit' in my Installed apps yet it still yiedls no results. My folder is like this.. MyBlog,MainBlog,build,djanggo-taggit is this correct? It is where pip installed it by default – user1074202 Aug 04 '12 at 02:39