Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: app with label XYZ could not be found. Are you sure your INSTALLED_APPS setting is correct?

Tags:

python

django

I'm trying to follow the Django tutorial (for v1.1) here. the problem that I'm running into is that it won't recognize my sample test app. For instance, I'm working in /home/user1234/rst . I can successfully run the server from there and create an app. However, if I create app "xyz" and then append 'rst.xyz' to my installed_apps list in settings.py, it doesn't seem to work. I get the following error message:

Error: App with label xyz could not be found. Are you sure your INSTALLED_APPS setting is correct?

I do see that there Near duplicate question, but the suggestions didn't seem to help.

My settings.py file includes:

INSTALLED_APPS = ( 
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'rst.xyz',

)

I have confirmed that mysql is running and that I can connect to the database. I am also running postresql and apache on the same machine (I'm not sure if that would cause an error).

Also, this might help:

 python -c "import sys; print sys.path"
 ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/pymodules/python2.6', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode', '/usr/local/lib/python2.6/dist-packages']

If anyone has any suggestions, I'd love to hear them!

like image 975
the_man_slim Avatar asked Apr 04 '12 21:04

the_man_slim


3 Answers

Okay I had a very similar problem and this might seem dumb but I spent hours trying to solve it before I realized what I was doing wrong.

What I did was put the app to the wrong location, instead of:

 INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',                                

)

I did:

 MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'polls',

)

While this may seem obvious when you read over it, there's a surprising amount of sites I found online where people were reporting the same error. I hope this saves someone all the trouble that I had to go through.

like image 167
uesports135 Avatar answered Nov 18 '22 22:11

uesports135


The app name on that you add to your installed apps should most likely be just xyz. Not project_dir.app_name

And to reaffirm what jvc26 asked. Django 1.1 is pretty custy, why are you starting with it instead of 1.4?

like image 31
John Avatar answered Nov 18 '22 23:11

John


at the start of project 2 directories are created by the same name (mysite in my case), both folders have a setting.py file so you need to change the installled apps setting in both the files.

like image 2
user3223789 Avatar answered Nov 18 '22 21:11

user3223789