Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: no such table: django_session

Tags:

django

I have found several topics with this title, but none of their solutions worked for me. I have two Django sites running on my server, both through Apache using different virtualhosts on two ports fed by my Nginx frontend (using for static files). One site uses MySql and runs just fine. The other uses Sqlite3 and gets the error in the title.

I downloaded a copy of sqlite.exe and looked at the mysite.sqlite3 (SQLite database in this directory) file and there is indeed a django_session table with valid data in it. I have the sqlite.exe in my system32 as well as the site-packages folder in my Python path.

Here is a section of my settings.py file:

MANAGERS = ADMINS  DATABASES = {     'default': {         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.         'NAME': 'mysite.sqlite3',         # Or path to database file if using sqlite3.         'USER': '',                      # Not used with sqlite3.         'PASSWORD': '',                  # Not used with sqlite3.         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.     } } 

I did use the python manage.py syncdb with no errors and just a "No Fixtures" comment.

Does anyone have any ideas what else might be going on here? I'm considering just transferring everything over to my old pal MySql and just ignoring Sqlite, as really it's always given me some kind of trouble. I was only using it for the benefit of knowing it anyway. I have no overwhelming reason why I should use it. But again, just for my edification does anyone know what this problem is? I don't like to give up.

like image 777
F_C Avatar asked Sep 02 '10 21:09

F_C


People also ask

How do I fix no such table in Django?

first step delete db. sqlite3 file . go to terminal and run commands: python manage.py makemigrations. python manage.py migrate.


1 Answers

It could be that the server uses a different working directory than the manage.py command. Since you provide a relative path to the sqlite database, it is created in the working directory. Try it with an absolute path, e.g.:

'NAME': '/tmp/mysite.sqlite3', 

Remember that you have to either run ./manage.py syncdb again or copy your current database with the existing tables to /tmp.

If it resolves the error message, you can look for a better place than /tmp :-)

like image 144
Benjamin Wohlwend Avatar answered Sep 22 '22 22:09

Benjamin Wohlwend