Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django settings.py not being detected

Tags:

python

django

I'm pretty new to Django and I'm having some difficulty getting my settings.py to load properly. I'm getting the following error:

ImproperlyConfigured at /admin

Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.

However, my settings.py INSTALLED_APPS looks as follows:

INSTALLED_APPS = (
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.admin',
     'squaredcrm' )

Looking through the error log, I've noticed its not picking up any of my changes to installed apps:

Django Version: 1.4.3 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles') Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

I cannot figure this out for the life of me. Any other changes seem to be working, but this field will not update. Any ideas?

like image 406
SquaredSoft Avatar asked Dec 20 '12 01:12

SquaredSoft


2 Answers

I know it's a silly question, but did you restart your server after making the changes?

By default, production (by which I mean Apache-based, and perhaps other) instances of Django do not auto-reload on changes. The Django development server will auto-reload, as long as you don't specifically tell it not to.

You have to restart (or stop and then start) an Apache-based Django for it to see the file changes.

Important tip: do not run a production site off of the development server. It is slow, slow, slow, and probably insecure in ways I don't know about.

like image 168
Peter Rowell Avatar answered Oct 18 '22 13:10

Peter Rowell


If other changes are picked up, this is probably because INSTALLED_APPS is being redefined somewhere in your settings.py file.

This could be:

  • At a subsequent line.
  • In an import (likely a from x import *).
like image 29
Thomas Orozco Avatar answered Oct 18 '22 12:10

Thomas Orozco