Hi,

I have been using django for about a year and a half. It has been
great. My hat is off to all the developers.

I am trying to port my project to django 1.0 for 0.97. I am using
MySQL. The ported version seems to be working well.

The problem is that am trying to add a new model that contains a
foreign key to an old model. For debugging I have stripped the new
model down to bare essentials. Here it is:

class XYZContent(models.Model):
    name=models.CharField(max_length=256, blank=False)
    disease=models.ForeignKey(MedicalBranch)

When I run syncdb, the table is created (I can see it with MySQL
Admin), but I get the following error:

----------------------------------------------------------------------------------------------------
C:\Documents and Settings\CCM\Desktop\pldev>python manage.py syncdb
Creating table medical_xyzcontent
Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "C:\Python24\Lib\site-packages\django\core\management
\__init__.py", line
340, in execute_manager
    utility.execute()
  File "C:\Python24\Lib\site-packages\django\core\management
\__init__.py", line
295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 77,
in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 96,
in execute
    output = self.handle(*args, **options)
  File "C:\Python24\Lib\site-packages\django\core\management\base.py",
line 178,
 in handle
    return self.handle_noargs(**options)
  File "C:\Python24\Lib\site-packages\django\core\management\commands
\syncdb.py"
, line 80, in handle_noargs
    cursor.execute(statement)
  File "C:\Python24\Lib\site-packages\django\db\backends\util.py",
line 19, in e
xecute
    return self.cursor.execute(sql, params)
  File "C:\Python24\Lib\site-packages\django\db\backends\mysql
\base.py", line 83
, in execute
    return self.cursor.execute(query, args)
  File "C:\Python24\lib\site-packages\MySQLdb\cursors.py", line 163,
in execute
    self.errorhandler(self, exc, value)
  File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line
35, in defau
lterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1005, "Can't create table '.\
\cwurld_pldev\
\#sql-f1c_3b.frm' (errno: 150)")
-----------------------------------------------------------------------------------------------------------


Here is the sql generated by the model:

BEGIN;
CREATE TABLE `content_algoxxx` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `name` varchar(256) NOT NULL,
    `disease_id` integer NOT NULL
)
;
ALTER TABLE `content_algoxxx` ADD CONSTRAINT
disease_id_refs_id_5c05e27d FOREIGN
 KEY (`disease_id`) REFERENCES `medical_medicalbranch` (`id`);
COMMIT;

I do not know if it matters, but the old table that is being
referenced is MyISAM, while the newly created table that contains the
reference is InnoDB.

Thanks,
Chuck






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to