﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21497	TypeError when running database migrate command	jbohman	Tim Graham <timograham@…>	"The TypeError appears when the index name is too long and must be hashed to fit. 

Added traceback below and will add a pull request very soon.

{{{
Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "".../lib/python3.3/site-packages/django/core/management/__init__.py"", line 416, in execute_from_command_line
    utility.execute()
  File "".../lib/python3.3/site-packages/django/core/management/__init__.py"", line 408, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "".../lib/python3.3/site-packages/django/core/management/base.py"", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "".../lib/python3.3/site-packages/django/core/management/base.py"", line 291, in execute
    output = self.handle(*args, **options)
  File "".../lib/python3.3/site-packages/django/core/management/commands/migrate.py"", line 124, in handle
    executor.migrate(targets, plan, fake=options.get(""fake"", False))
  File "".../lib/python3.3/site-packages/django/db/migrations/executor.py"", line 60, in migrate
    self.apply_migration(migration, fake=fake)
  File "".../lib/python3.3/site-packages/django/db/migrations/executor.py"", line 94, in apply_migration
    migration.apply(project_state, schema_editor)
  File "".../lib/python3.3/site-packages/django/db/migrations/migration.py"", line 97, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "".../lib/python3.3/site-packages/django/db/migrations/operations/models.py"", line 26, in database_forwards
    schema_editor.create_model(model)
  File "".../lib/python3.3/site-packages/django/db/backends/schema.py"", line 209, in create_model
    ""name"": self._create_index_name(model, [field.column], suffix=""_fk_%s_%s"" % (to_table, to_column)),
  File "".../lib/python3.3/site-packages/django/db/backends/schema.py"", line 706, in _create_index_name
    index_name = hashlib.md5(index_name).hexdigest()[:self.connection.features.max_index_name_length]
TypeError: Unicode-objects must be encoded before hashing
}}}
"	Bug	closed	Migrations	dev	Normal	fixed			Accepted	1	0	1	0	0	0
