Reputation: 81
I'm new with django 1.10 using mysql (5.6.17) (WAMP 2.5) and Python 3.5 under Windows 8.1
I configured fine the mysql connector, I made my models, made makemigrations myapp
and migrate myapp
, using manage.py terminal with Pycharm.
When I try to acces in admin web page, I have this message (trabajo is my app inside my project: programa)
Exception Value:
(1146, "Table 'programa.django_session' doesn't exist")
In my settings.py file have:
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'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',
]
The apps block:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'trabajo',
]
To connect the database:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME' : 'programa',
'USER' : 'myownuser',
'PASSWORD' : 'myownpassword',
'HOST' : '',
'PORT' : '',
}
}
Why have this error in the admin page? What can I do to solve this?
Thanks in advance. Any help is welcome!! ;-)
Gustavo.
Upvotes: 7
Views: 17553
Reputation: 628
I ran into the same problem, my issue was that migration history had recorded that it had successfully created a table for session
even though it hadn't actually done so on my MySQL DB.
I was able to fix it by running command:
python manage.py migrate --fake sessions zero
Then:
python manage.py migrate sessions
Upvotes: 3
Reputation: 57
File "C:\Python39\lib\site-packages\MySQLdb\connections.py", line 259, in query_mysql.connection.query(self, query) MySQLdb._exceptions.ProgrammingError: (1146, "Table
'database_name.django_session' doesn't exist")
python manage.py migrate sessions
Upvotes: 2
Reputation: 10389
if all you did was "migrate myapp", then you only created the tables for your app. I think a plain "migrate" will create all the tables for Django and it's contributed modules.
Upvotes: 10