Opened 9 years ago

Closed 9 years ago

#24884 closed Uncategorized (invalid)

Migrations created in Python2.7 fail in Python3.4

Reported by: Chris Mitchell Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

A migration file created with Python2.7 is failing with the following error in Python3.4:

  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/migrations/executor.py", line 147, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/migrations/operations/models.py", line 59, in database_forwards
    schema_editor.create_model(model)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/backends/base/schema.py", line 261, in create_model
    self.quote_name(field.column),
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/backends/base/schema.py", line 114, in quote_name
    return self.connection.ops.quote_name(name)
  File "/home/chris/.virtualenvs/djangui3/lib/python3.4/site-packages/Django-1.8.2-py3.4.egg/django/db/backends/sqlite3/operations.py", line 98, in quote_name
    if name.startswith('"') and name.endswith('"'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

The offending entry in my migration is:

('_value', models.TextField(db_column=b'value')),

Removal of the b allows migration to carry on.

Change History (1)

comment:1 by Tim Graham, 9 years ago

Resolution: invalid
Status: newclosed

Please see Supporting Python 2 and 3 in the migrations topic guide.

Note: See TracTickets for help on using tickets.
Back to Top