Table django_session don't exists when I try use admin with mysql
12,062
Solution 1
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.
Solution 2
Run command:
python manage.py migrate sessions
Solution 3
I got this error:
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")
and solved by the following command:
python manage.py migrate sessions
Author by
Gustux
Updated on June 15, 2022Comments
-
Gustux almost 2 years
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
andmigrate 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.
-
Gustux almost 8 yearsThank buddy! I made
makemigrations
andmigrate
and works!! -
Omkar over 4 yearsThis will not work ! Below worked - python manage.py migrate