Issue
The program was quite running well a few minutes ago, after adding SlugField to my post URLs which I feel like it has nothing to do with the error, this is what I get when I run Python3 manage.py runserver
in my terminal.
System check identified some issues:
WARNINGS:
base.Post.tags: (fields.W340) null has no effect on ManyToManyField.
System check identified 1 issue (0 silenced).
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 394, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: unsupported file format
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/peace/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/peace/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
self.check_migrations()
File "/home/peace/.local/lib/python3.6/site-packages/django/core/management/base.py", line 458, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/peace/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/peace/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/home/peace/.local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 76, in applied_migrations
if self.has_table():
File "/home/peace/.local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
return get_names(cursor)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/base/introspection.py", line 43, in get_names
return sorted(ti.name for ti in self.get_table_list(cursor)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/introspection.py", line 73, in get_table_list
ORDER BY name""")
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "/home/peace/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 394, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: unsupported file format
I'm just not really sure if I should change something since there is an unsupported file format. Just not even sure about the file it's talking about :( Is it a bug or there is something I'm doing wrong?
Solution
I would recommend deleting your sqlite3 and migrations folders and then run the following:
python3 manage.py makemigrations <app>
python3 manage.py migrate
python3 manage.py runserver
You may refer to this link for deleting migration: https://riptutorial.com/django/example/29416/resetting-django-migration--deleting-existing-database-and-migrating-as-fresh
Answered By - Ahmed Ablak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.