Django version:5.0
Database backend:Sql-server
DATABASES = {
"default": {
"ENGINE": "mssql",
"NAME": "DB_name",
"USER": "sa",
"PASSWORD": "password",
"HOST": "192.X.X.X\SQLEXPRESS",
"PORT": "1433",
"OPTIONS": {"driver": "ODBC Driver 17 for SQL Server",
},
}
}
i used with exsiting DB and run
python manage.py makemigrations
python manage.py migrate --fake-initial
as
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> **python manage.py makemigrations**
Migrations for 'ERPapp':
ERPapp\migrations\0001_initial.py
- Create model Cities
- Create model Clienttypes
- Create model Componentlinks
- Create model Componentlinksstandarddescriptions
- Create model ComponentLinkType
- Create model Componentsmanufacter
- Create model Componentsofdeliverysertificate
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> **python manage.py migrate --fake-initial**
Operations to perform:
Apply all migrations: ERPapp, admin, auth, authtoken, contenttypes, sessions
Running migrations:
Applying ERPapp.0001_initial... FAKED
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 22, in <module>
main()
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\commands\migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\migration.py", line 132, in apply
operation.database_forwards(
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\operations\models.py", line 659, in database_forwards
alter_together(
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\schema.py", line 191, in alter_unique_together
self.execute(sql)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\schema.py", line 1156, in execute
sql = str(sql)
^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\ddl_references.py", line 220, in __str__
return self.template % self.parts
~~~~~~~~~~~~~~^~~~~~~~~~~~
KeyError: 'nulls_distinct'
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> **pip install --upgrade django-mssql-backend**
Requirement already satisfied: django-mssql-backend in c:\users\sara\appdata\local\programs\python\python311\lib\site-packages (2.8.1)
Requirement already satisfied: pyodbc>=3.0 in c:\users\sara\appdata\local\programs\python\python311\lib\site-packages (from django-mssql-backend) (4.0.35)
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> **python manage.py migrate --fake ERPapp zero**
Traceback (most recent call last):
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 22, in <module>
main()
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\commands\migrate.py", line 117, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\recorder.py", line 90, in applied_migrations
return {
^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 398, in __iter__
self._fetch_all()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 1926, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 91, in __iter__
results = compiler.execute_sql(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 1549, in execute_sql
sql, params = self.as_sql()
^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\compiler.py", line 235, in as_sql
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\compiler.py", line 421, in compile
return super().compile(node, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 546, in compile
sql, params = node.as_sql(self, self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\where.py", line 179, in as_sql
raise FullResultSet
django.core.exceptions.FullResultSet
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> python -m django --version
5.0
PS C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django> python manage.py showmigrations
Traceback (most recent call last):
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 22, in <module>
main()
File "C:\Users\sara\Desktop\Clone ERPApp\27.12.23\ERPapp\api_django\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\commands\showmigrations.py", line 66, in handle
return self.show_list(connection, options["app_label"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\commands\showmigrations.py", line 85, in show_list
loader = MigrationLoader(connection, ignore_no_migrations=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\loader.py", line 58, in __init__
self.build_graph()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\loader.py", line 235, in build_graph
self.applied_migrations = recorder.applied_migrations()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\recorder.py", line 90, in applied_migrations
return {
^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 398, in __iter__
self._fetch_all()
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 1926, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\query.py", line 91, in __iter__
results = compiler.execute_sql(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 1549, in execute_sql
sql, params = self.as_sql()
^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\compiler.py", line 235, in as_sql
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\mssql\compiler.py", line 421, in compile
return super().compile(node, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\compiler.py", line 546, in compile
sql, params = node.as_sql(self, self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sara\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\sql\where.py", line 179, in as_sql
raise FullResultSet
django.core.exceptions.FullResultSet
how can fix this error??