> > If MySQL reports an error number 1005 from a CREATE TABLE statement, and > the error message refers to error 150, table creation failed because a > foreign key constraint was not correctly formed. Similarly, if an ALTER > TABLE fails and it refers to error 150, that means a foreign key > definition would be incorrectly formed for the altered table. > (source)<http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html> >
Error suggests the problem with table team. It creates references to: - auth_user - team_owners - soc_league - the_player - the_coach Since MySQL is trying to create table, it seems that you have deleted all the tables from database. I guess you're trying to define a table with a reference (FK) to a table that is not yet defined. Where are soc_league and team_owners defined? Did you try running everything in db.py and after the tables are defined, moving some of them to conditional models? And answer to your question. On each request, models from these directories are executed: - models/* - models/controller_name/* - models/controller_name/function_name/* --