When I include a ModelToModelField
to one of my models the following error is thrown.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.6/site-packages/django/core/management/commands/syncdb.py", line 93, in handle_noargs
cursor.execute(statement)
File "/Library/Python/2.6/site-packages/django/db/backends/util.py", line 19, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 84, in execute
return self.cursor.execute(query, args)
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/cursors.py", line 173, in execute
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
_mysql_exceptions.OperationalError: (1050, "Table 'orders_proof_approved_associations' already exists")
Field definition:
proof_storage = FileSystemStorage(location=settings.FILE_UPLOAD_ROOT)
class Proof(mixins.ModifiedDates):
"""
Each Order eventually has a Proof or multiple rounds of Proofs. Required are a proof file and
a Record Set file containing the records used for the proof.
"""
def get_upload_path(instance, filename):
proof_count = int(Proof.objects.filter(order=instance.order).count()) + 1
destination_path = os.path.join(instance.order.ATTACHMENTS_RELATIVE_ROOT, 'proofs')
return os.path.join(destination_path, '%02d_%s' % (proof_count, filename))
file = models.FileField(storage=proof_storage, upload_to=get_upload_path)
approved = models.BooleanField(default=0)
order = models.ForeignKey(Order)
record_set_file = models.FileField(storage=proof_storage, upload_to=get_upload_path)
approved_associations = models.ManyToManyField(Association)
Everything works fine when I remove the field, and the table is no where in sight.
Any thoughts as to why this would happen?