Reputation: 185
I am trying to setup my environment using VS code, and I have noticed that when i run the python manage.py migrate command I get the following errors. Its strange because the project is new one, from the research I did I noticed that some people were getting the error because they changed some files etc, in my case I have not changed any file. its a new clean project.
All I have done is removed the default sqllite database and replaced this with a SQL server database configuration. I noticed that 2 tables gets created, that is django_content_type and django_migrations then the process fails, is it possible to get some kind of verbose logs to see what the issue is ?
The error details that I have are below.
(env) PS C:\Users\User\Documents\django\feature\django\deployment_reporting\reporting_project> python manage.py makemigrations
No changes detected
(env) PS C:\Users\User\Documents\django\feature\django\deployment_reporting\reporting_project> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\reporting_project\manage.py", line 22, in <module>
main()
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\reporting_project\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\core\management\commands\migrate.py", line 244, in handle
post_migrate_state = executor.migrate(
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\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 "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\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 "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\db\migrations\executor.py", line 227, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\db\migrations\migration.py", line 126, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\db\migrations\operations\models.py", line 528, in database_forwards
alter_together(
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\sql_server\pyodbc\schema.py", line 156, in alter_unique_together
self.execute(sql)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\sql_server\pyodbc\schema.py", line 861, in execute
sql = str(sql)
File "C:\Users\User\Documents\django\feature\django\deployment_reporting\env\lib\site-packages\django\db\backends\ddl_references.py", line 201, in __str__
return self.template % self.parts
KeyError: 'include'
I added the below to my settings file.
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc',
'NAME': 'django_reporting',
'HOST': 'DESKTOP-OI\DEV2',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
},
},
}
Upvotes: 1
Views: 271
Reputation: 185
Thanks to ruffishkimbr, there was a typo in his answer and in order not to confuse anyone. I am posting what I did here. First of all, I am running django version 3.2.6
what I did was to follow ruffishkimbr instructions. Uninstall pyodby by running
python -m pip uninstall pyodbc
Then installed django-pyodbc-azure-2019 by running
python -m pip install django-pyodbc-azure-2019
Upvotes: 0
Reputation: 76
I found another answer to this issue from somewhere else, let me know if it helps c:
" I do following:
uninstall this using pip uninstall django-pyodbc or pip3 uninstall django-pyodbc (for Linux)
install this using pip uninstall django-pyodbc-azure-2019 or pip3 uninstall django-pyodbc-azure-2019 (for Linux)
My Issue is resolved and hope your app will run smoothly after this. :-) "
I usually work with postgresql databases so never seen this issue personally.
Upvotes: 1