Q:

ImproperlyConfigured at /admin/ error

I'm creating a Django app and I was trying to set the interface administration. But when I'm running admin url, I'm getting an error. I've seen this question several times here and I've been trying the differents solutions, but none works for me. The error that I get is:
ImproperlyConfigured at /admin/
You're using the Django "sites framework" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.

Site is a table on my database to describe a place and SITE_ID is its ID, it is created on my django files as well as in my database.
My urls.py file is:
urlpatterns = patterns('',
   (r'^$', mydb),  
    (r'^mydb/$', mydb),  
    (r'^time/$', current_datetime),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

My settings.py is configured as:
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

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

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',
)

ROOT_URLCONF = 'mydb.urls'

WSGI_APPLICATION = 'mydb.wsgi.application'

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',   # Which database engine to use
    'NAME': 'mydb',                   # The name of the database
    'USER': 'root',                         # The username to use when connecting to the database
    'PASSWORD': 'mypassword',           # The password to use when connecting to your database
    'HOST': '',                             # The host to use when connecting to the database. Set empty string for localhost
    'PORT': '3306',                         # The port to use when connecting to the database. Set empty string for default
}
}

LANGUAGE_CODE = 'en-CA'

TIME_ZONE = 'America/Montreal'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static').replace('\\','/'),
)

TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates').replace('\\','/'),
)

My SITE model on models.py is like:
class Site(models.Model):
site_id = models.IntegerField(db_column='Site_ID', primary_key=True) # Field name made lowercase.
site_name = models.CharField(db_column='Site_name', max_length=100) # Field name made lowercase.
site_type = models.TextField(db_column='Site_type') # Field name made lowercase.
watershed = models.ForeignKey('Watershed', db_column='Watershed_ID', blank=True, null=True) # Field name made lowercase.
description = models.TextField(db_column='Description') # Field name made lowercase.
picture = models.TextField(db_column='Picture', blank=True) # Field name made lowercase.
street_number = models.CharField(db_column='Street_number', max_length=100, blank=True) # Field name made lowercase.
street_name = models.CharField(db_column='Street_name', max_length=100, blank=True) # Field name made lowercase.
city = models.TextField(db_column='City', blank=True) # Field name made lowercase.
zip_code = models.CharField(db_column='Zip_code', max_length=100, blank=True) # Field name made lowercase.
province = models.TextField(db_column='Province') # Field name made lowercase.
country = models.TextField(db_column='Country') # Field name made lowercase.
class Meta:
    managed = False
    db_table = 'site'

And all is called to the admin.py file:
from django.contrib import admin
from app.models import Site

admin.site.register(Site)

I've other tables into the database, but (at the moment) I'm just getting this error with this ID and I don't know how to fix it.
Thanks in advance.

A:

You forgot to set the SITE_ID in your settings file.
And you don't need a custom Site model, it's build in :)
from django.contrib.sites.models import Site

