vendredi 15 janvier 2016

Django 1.9 no such table

I am migrating an old django site up to version 1.9. For testing purposes I am using a sqlite database with the below configuration.

DATABASES = {
 'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': 'testingsqlitedb',
    },
}

When I go to the login page for the /admin/ url I receive

OperationalError at /admin/login/
no such table: auth_user


Traceback:

File "/home/ubuntu/workspace/venv/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/ubuntu/workspace/venv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py" in execute
  323.         return Database.Cursor.execute(self, query, params)

The above exception (no such table: auth_user) was the direct cause of the following exception:


File "/home/ubuntu/workspace/venv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py" in execute
  323.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /admin/login/
Exception Value: no such table: auth_user

However the problem is that the query that fails according to the trace does not really fail. If I use manage.py and dbshell I can execute the below query and return my admin user.

('SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", '
 '"auth_user"."is_superuser", "auth_user"."username", '
 '"auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", '
 '"auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" '
 'FROM "auth_user" WHERE "auth_user"."username" = 'admin')

What could be causing the Django app to fail at making the query while I am able to make it via dbshell?

Edit

I am running with

/home/ubuntu/workspace/venv/bin/python /home/ubuntu/workspace/manage.py runserver $IP:$PORT

and executing the query manually via

source venv/bin/activate
python manage.py dbshell
(query that is listed above)

Aucun commentaire:

Enregistrer un commentaire