Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: startswith first arg must be bytes or a tuple of bytes, not str #194

Open
ghost opened this issue Feb 12, 2019 · 0 comments
Open

Comments

@ghost
Copy link

ghost commented Feb 12, 2019

I'm trying to create a new model, nothing strange, some ForeignKey to CharField is the strangest.
When I try to migrate, this error is shown:

File "manage.py", line 18, in
execute_from_command_line(sys.argv)
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/init.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/project_folder/venv3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 203, in handle
fake_initial=fake_initial,
File "/project_folder/venv3/lib/python3.6/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 "/project_folder/venv3/lib/python3.6/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 "/project_folder/venv3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 106, in exit
self.execute(sql)
File "/project_folder/venv3/lib/python3.6/site-packages/sql_server/pyodbc/schema.py", line 642, in execute
sql = str(sql)
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 175, in str
return self.template % self.parts
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 91, in str
return ', '.join(col_str(column, idx) for idx, column in enumerate(self.columns))
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 91, in
return ', '.join(col_str(column, idx) for idx, column in enumerate(self.columns))
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 87, in col_str
return self.quote_name(column) + self.col_suffixes[idx]
File "/project_folder/venv3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 136, in quote_name
return self.connection.ops.quote_name(name)
File "/project_folder/venv3/lib/python3.6/site-packages/sql_server/pyodbc/operations.py", line 246, in quote_name
if name.startswith('[') and name.endswith(']'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

A you can see, I am using django 2.1.5 and python 3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants