Django python manage.py makemigrations causes a problem with databases - python

I am starting with Django and I got this problem. I understand only that there is a problem with database. I would really like to get some help. Thank you, If it is important I use Fedora 33
Guys really, not my bad that the 90% of problem is code, let me as a question XD
(project_venv) [mikolajwojtowicz#localhost src]$ python3 manage.py makemigrations
Traceback (most recent call last):
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 411, in execute
return Database.Cursor.execute(self, query)
sqlite3.DatabaseError: file is not a database
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mikolajwojtowicz/Django/my_project/src/manage.py", line 22, in <module>
main()
File "/home/mikolajwojtowicz/Django/my_project/src/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/migrations/loader.py", line 290, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations
if self.has_table():
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 56, in has_table
tables = self.connection.introspection.table_names(cursor)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/base/introspection.py", line 48, in table_names
return get_names(cursor)
File "/home/mikolajwojtowicz/.local/lib/python3.9/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/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/sqlite3/introspection.py", line 74, in get_table_list
cursor.execute("""
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/home/mikolajwojtowicz/.local/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 411, in execute
return Database.Cursor.execute(self, query)
django.db.utils.DatabaseError: file is not a database

The error log says:
sqlite3.DatabaseError: file is not a database
This means that your settings for the database are wrong. This setting is located in the settings.py in your core project's directory (this directory will also have wsgi.py and asgi.py)
Make sure your settings for db engine, name, user, and password are correct

Related

Q: Python Django Docker - Unknown server host 'db' error when trying to make a super user

I am trying to use the command python manage.py createsuperuser and docker exec -it veganetwork-db-1 python manage.py createsuperuser to add myself as a superuser to my microservices project, however when I try to run both of these commands I get Unknown server host 'db' in my Windows Powershell, here is the entire error:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'veganetwork.auth_user' doesn't exist")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/manage.py", line 22, in <module>
main()
File "/app/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in execute
return super().execute(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 100, in handle
default_username = get_default_username()
File "/usr/local/lib/python3.9/site-packages/django/contrib/auth/management/__init__.py", line 140, in get_default_username
auth_app.User._default_manager.get(username=default_username)
File "/usr/local/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 425, in get
num = len(clone)
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 269, in __len__
self._fetch_all()
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'veganetwork.auth_user' doesn't exist")
PS C:\Users\trevo\OneDrive\Desktop\veganetwork\veganetworkmain> python manage.py migrate auth
Traceback (most recent call last):
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\__init__.py", line 123, in Connect
return Connection(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2005, "Unknown server host 'db' (11001)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\trevo\OneDrive\Desktop\veganetwork\veganetworkmain\manage.py", line 22, in <module>
main()
File "C:\Users\trevo\OneDrive\Desktop\veganetwork\veganetworkmain\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\migrate.py", line 75, in handle
self.check(databases=[database])
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\database.py", line 13, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 405, in sql_mode
sql_mode = self.mysql_server_data['sql_mode']
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 366, in mysql_server_data
with self.temporary_connection() as cursor:
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 117, in __enter__
return next(self.gen)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
with self.cursor() as cursor:
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
self.ensure_connection()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
self.connect()
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\__init__.py", line 123, in Connect
return Connection(*args, **kwargs)
File "C:\Users\trevo\AppData\Local\Programs\Python\Python39\lib\site-packages\MySQLdb\connections.py", line 185, in __init__
super().__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2005, "Unknown server host 'db' (11001)")
I have tried some other methods in some other posts like creating a class named Command in my manage.py script to create the superuser: Create django super user in a docker container without inputting password, using docker-compose run django python manage.py createsuperuser rather than the regular docker command which is docker exec -it veganetwork-db-1 python manage.py createsuperuser: https://github.com/vchaptsev/cookiecutter-django-vue/issues/25, and finally trying to change the depends_on variable inside my docker-compose.yml file and restarting the docker container itself: django.db.utils.OperationalError: (2005, "Unknown MySQL server host 'db' (-2)"). I have tried all of these solutions but they have all failed.
here is my docker-compose file as well as my dockerfile:
version: '3.9'
services:
backend:
build:
context: .
dockerfile: dockerfile
command: 'python manage.py runserver 0.0.0.0:8000'
ports:
- 8000:8000
volumes:
- .:/app
depends_on:
- db
db:
image: mysql:5.7.22
restart: always
environment:
MYSQL_DATABASE: veganetworkmain
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
volumes:
- .dbdata:/var/lib/mysql
ports:
- 3306:3306
dockerfile:
FROM python:3.9
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
CMD python manage.py runserver 0.0.0.0:8000
What exactly am I doing wrong here, thank you!

django.db.utils.DatabaseError with Django and Djongo

I keep running into the django.db.utils.DatabaseError error with trying to migrate the database changes in a Django project.
Terminal Output:
Running migrations:
Not implemented alter command for SQL ALTER TABLE "project_name_user" ALTER COLUMN "age" TYPE double
Applying project_name.0002_auto_20210415_1452...Traceback (most recent call last):
File "...\.venv\lib\site-packages\djongo\cursor.py", line 51, in execute
self.result = Query(
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 783, in __init__
self._query = self.parse()
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 875, in parse
raise e
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 856, in parse
return handler(self, statement)
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 888, in _alter
query = AlterQuery(self.db, self.connection_properties, sm, self._params)
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 425, in __init__
super().__init__(*args)
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 84, in __init__
super().__init__(*args)
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 62, in __init__
self.parse()
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 441, in parse
self._alter(statement)
File "...\.venv\lib\site-packages\djongo\sql2mongo\query.py", line 500, in _alter
raise SQLDecodeError(f'Unknown token: {tok}')
djongo.exceptions.SQLDecodeError:
Keyword: Unknown token: TYPE
Sub SQL: None
FAILED SQL: ('ALTER TABLE "project_name_user" ALTER COLUMN "age" TYPE double',)
Params: ([],)
Version: 1.3.4
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "...\.venv\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
djongo.database.DatabaseError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "...\manage.py", line 22, in <module>
main()
File "...\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "...\.venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "...\.venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "...\.venv\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "...\.venv\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "...\.venv\lib\site-packages\django\core\management\base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "...\.venv\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle
post_migrate_state = executor.migrate(
File "...\.venv\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "...\.venv\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "...\.venv\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "...\.venv\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "...\.venv\lib\site-packages\django\db\migrations\operations\fields.py", line 249, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "...\.venv\lib\site-packages\django\db\backends\base\schema.py", line 564, in alter_field
self._alter_field(model, old_field, new_field, old_type, new_type,
File "...\.venv\lib\site-packages\django\db\backends\base\schema.py", line 710, in _alter_field
self.execute(
File "...\.venv\lib\site-packages\django\db\backends\base\schema.py", line 142, in execute
cursor.execute(sql, params)
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "...\.venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "...\.venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "...\.venv\lib\site-packages\djongo\cursor.py", line 59, in execute
raise db_exe from e
django.db.utils.DatabaseError
I am stumped on how to solve this issue. I have tried sqlparse==0.2.4 as suggested here but it did not work for me.
Deleted everything in the migrations folder and started from scratch. The same error pops up but now it is even longer.
I understand there is a not implemented error but not sure how to fix it.
The models.py:
from djongo import models
class User(models.Model):
age = models.FloatField()
height = models.FloatField()
waist = models.FloatField()
weight = models.FloatField()

django.db.utils.OperationalError: Problem installing fixtures: no such table: pages_page__old

When I try to run: python3 manage.py createdb
after I add my password I get an error, after the superuser create successfully. and the finish of the following error is :
django.db.utils.OperationalError: Problem installing fixtures: no such table: pages_page__old
The full error :
Traceback (most recent call last):
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: no such table: pages_page__old
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/martaf/Travail_insPYration/shop/manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/mezzanine/core/management/commands/createdb.py", line 61, in handle
func()
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/mezzanine/core/management/commands/createdb.py", line 109, in create_pages
call_command("loaddata", "mezzanine_required.json")
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/__init__.py", line 131, in call_command
return command.execute(*args, **defaults)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/core/management/commands/loaddata.py", line 115, in loaddata
connection.check_constraints(table_names=table_names)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 276, in check_constraints
cursor.execute(
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
File "/home/martaf/Travail_insPYration/shop/env/lib64/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 326, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: Problem installing fixtures: no such table: pages_page__old

Django Upgrade : relation "django_content type" does not exist

I upgraded my django version from 1.7.5 to 1.9.2. All migration ran but when i run tests i get below error.
django.db.utils.ProgrammingError: relation "django_content_type" does not exist
I checked the database and the django_content_type model exists. I am using PostgreSQL.
I am only getting this error on PostgreSQL not in Sqlite3..
Traceback
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 129, in
utility.execute()
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 104, in execute
PycharmTestCommand().run_from_argv(self.argv)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_manage.py", line 91, in handle
failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive, failfast=failfast, keepdb='--keepdb' in sys.argv)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_runner.py", line 256, in run_tests
extra_tests=extra_tests, **options)
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_test_runner.py", line 156, in run_tests
return super(DjangoTeamcityTestRunner, self).run_tests(test_labels, extra_tests, **kwargs)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/test/runner.py", line 532, in run_tests
old_config = self.setup_databases()
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/test/runner.py", line 482, in setup_databases
self.parallel, **kwargs
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/test/runner.py", line 726, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 70, in create_test_db
run_syncdb=True,
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/__init__.py", line 119, in call_command
return command.execute(*args, **defaults)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 172, in handle
self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 293, in sync_apps
cursor.execute(statement)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/Mac/my_env_test/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "django_content_type" does not exist
I used uuid field and JSON field in old Django version but in new version these fields are default provided by django models. So i replaced these fields with django default fields and created migrations again....
Now Its working without any issue..

django.db.utils.OperationalError: (1426, "Too big precision 1000

I get the folling problem when I try to run python2.7 manage.py syncdb on webfaction. Apologies if I am not providing the right info as I am very new to this.
Creating table carts_cartitem
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/syncdb.py", line 27, in handle_noargs
call_command("migrate", **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/__init__.py", line 115, in call_command
return klass.execute(*args, **defaults)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/migrate.py", line 128, in handle
created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/core/management/commands/migrate.py", line 239, in sync_apps
cursor.execute(statement)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/utils.py", line 63, in execute
return self.cursor.execute(sql)
File "/home/user/webapps/myproject/lib/python2.7/Django-1.7.1-py2.7.egg/django/db/backends/mysql/base.py", line 128, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1426, "Too big precision 1000 specified for column 'line_total'. Maximum is 65.")
Please excuse my lack of knowledge here, I seemed to have solved this by running python manage.py migrate --fake and now I am no longer getting any of the previous errors.

Categories