﻿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
18256	"MySQL error (1005, ""Can't create table '\\db_name\\.#sql-4a8_98' (errno: 150)"") in Django 1.4"	Hans Andersen	nobody	"I am getting MySQL (errno: 150) while trying to run syncdb.

I have tested the same model code on Django 1.3.1 and found no problems in running syncdb, so the issue seems to has been introduced in Django 1.4, and is affecting Django 1.4+, as I has also tested on Django SVN.

My system info are:
* Ubuntu 12.04
* Python 2.7.3
* Django 1.4
* MySQL 5.5.22

My models are:
{{{#!python
from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _

class Report(models.Model):
	TOPIC_CHOICES = (
	...
	)

	user = models.ForeignKey(User)
	topic = models.PositiveSmallIntegerField(_('Report topic'), choices=TOPIC_CHOICES, default=None)
	custom_text = models.TextField(_(""Further comments""), \
		help_text=_(""It is important to give as precise a description, with as many details, of the problem as possible, for our development team to be able properly to determine your problem.""))
	fixed = models.BooleanField(_(""The reported problem is fixed.""), default=False)

class ReportUnit(models.Model):
	TEASING_CHOICES = (
	...
	)

	report = models.OneToOneField(Report)
	tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES, default=None)

class ReportAdvertisement(models.Model):
	TEASING_CHOICES = (
	...
	)

	report = models.OneToOneField(Report)
	tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES, default=None)

class ReportStatistics(models.Model):
	TEASING_CHOICES = (
	...
	)

	report = models.OneToOneField(Report)
	tease = models.PositiveSmallIntegerField(choices=TEASING_CHOICES, default=None)
}}}

Python traceback:
{{{
Creating tables ...
Creating table table_name
Traceback (most recent call last):
  File ""/home/user/workspace/project/manage.py"", line 25, in <module>
    execute_manager(settings)
  File ""/usr/lib/python2.7/dist-packages/django/core/management/__init__.py"", line 438, in execute_manager
    utility.execute()
  File ""/usr/lib/python2.7/dist-packages/django/core/management/__init__.py"", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/usr/lib/python2.7/dist-packages/django/core/management/base.py"", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/usr/lib/python2.7/dist-packages/django/core/management/base.py"", line 220, in execute
    output = self.handle(*args, **options)
  File ""/usr/lib/python2.7/dist-packages/django/core/management/base.py"", line 351, in handle
    return self.handle_noargs(**options)
  File ""/usr/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py"", line 101, in handle_noargs
    cursor.execute(statement)
  File ""/usr/lib/python2.7/dist-packages/django/db/backends/util.py"", line 34, in execute
    return self.cursor.execute(sql, params)
  File ""/usr/lib/python2.7/dist-packages/django/db/backends/mysql/base.py"", line 86, in execute
    return self.cursor.execute(query, args)
  File ""/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py"", line 174, in execute
    self.errorhandler(self, exc, value)
  File ""/usr/lib/python2.7/dist-packages/MySQLdb/connections.py"", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1005, ""Can't create table '\\db_name\\.#sql-4a8_ab' (errno: 150)"")
}}}"	Bug	closed	Documentation	1.4	Normal	fixed	mysql	hans@… timograham@…	Accepted	1	0	0	0	0	0
