Hello, after creating a first database, I ran
$ python manage.py makemigrations
but then I get the error :
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
Hello, after creating a first database, I ran
$ python manage.py makemigrations
but then I get the error :
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
I think you probably need to run "python manage.py migrate" first so that it can get all of the standard database tables in place.
Whatever command I try to run (including "python manage.py migrate") I get the same error :
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
I also tried to remove the database and re-create it but to no avail.
Could you paste the full output of the "python manage.py migrate" command? It might be useful to know what it's printing out before it gets to that error.
Sure. Here it is :
$ python manage.py migrate
Traceback (most recent call last):
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 116, in populate
app_config.ready()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/TreecheckerSTG/treechecker-server/api/admin.py", line 126, in <module>
LogEntry.objects.all().delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 620, in delete
deleted, _rows_count = collector.delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/deletion.py", line 284, in delete
count = qs._raw_delete(using=self.using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 634, in _raw_delete
return sql.DeleteQuery(self.model).delete_qs(self, using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/subqueries.py", line 80, in delete_qs
cursor = self.get_compiler(using).execute_sql(CURSOR)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
Sure. Here it is :
$ python manage.py migrate
Traceback (most recent call last):
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 116, in populate
app_config.ready()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/TreecheckerSTG/treechecker-server/api/admin.py", line 126, in <module>
LogEntry.objects.all().delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 620, in delete
deleted, _rows_count = collector.delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/deletion.py", line 284, in delete
count = qs._raw_delete(using=self.using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 634, in _raw_delete
return sql.DeleteQuery(self.model).delete_qs(self, using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/subqueries.py", line 80, in delete_qs
cursor = self.get_compiler(using).execute_sql(CURSOR)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
Try rolling back the migration for the admin app:
python manage.py migrate admin zero
if that still give the error, try faking the reverse migration:
python manage.py migrate admin zero --fake
After one of those has worked, you should be able to migrate as normal.
I have just tried both commands but they both seem to give the same results:
$ python manage.py migrate admin zero --fake
Traceback (most recent call last):
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/apps/registry.py", line 116, in populate
app_config.ready()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/TreecheckerSTG/treechecker-server/api/admin.py", line 126, in <module>
LogEntry.objects.all().delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 620, in delete
deleted, _rows_count = collector.delete()
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/deletion.py", line 284, in delete
count = qs._raw_delete(using=self.using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/query.py", line 634, in _raw_delete
return sql.DeleteQuery(self.model).delete_qs(self, using)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/subqueries.py", line 80, in delete_qs
cursor = self.get_compiler(using).execute_sql(CURSOR)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 101, in execute
return self.cursor.execute(query, args)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/cursors.py", line 312, in _query
db.query(q)
File "/home/TreecheckerSTG/.virtualenvs/trckvirtualenv/lib/python3.6/site-packages/MySQLdb/connections.py", line 224, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'TreecheckerSTG$db.django_admin_log' doesn't exist")
Ah! I see it! This line in the traceback:
File "/home/TreecheckerSTG/treechecker-server/api/admin.py", line 126, in <module>
LogEntry.objects.all().delete()
tells me that you have a line in one of your files that is trying to use the admin LogEntry model at import-time and, since you have not yet created the tables for that model to be valid, it's failing. Either remove that line, or wrap it in a try...except so that it does not error when Django tries to import the module when you're running migrations.
Indeed! That is right, I remember I added that line and I will now remove it. Sorry... Thank you so much!!!
No problem. Glad we got there eventually.