Permalink
Browse files

Fixing references in MySQLDatabase to "field.to" that was changed to

"field.rel_model" -- fixes #120
  • Loading branch information...
1 parent cdc3fbc commit f4aae7605e7d7dc043775aa0c77db261fddfd9b0 @coleifer committed Oct 17, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 peewee.py
View
6 peewee.py
@@ -1738,16 +1738,16 @@ def create_foreign_key(self, model_class, field):
db_table = model_class._meta.db_table
constraint = 'fk_%s_%s_%s' % (
db_table,
- field.to._meta.db_table,
+ field.rel_model._meta.db_table,
field.db_column,
)
query = framing % {
'table': self.quote(db_table),
'constraint': self.quote(constraint),
'field': self.quote(field.db_column),
- 'to': self.quote(field.to._meta.db_table),
- 'to_field': self.quote(field.to._meta.primary_key.db_column),
+ 'to': self.quote(field.rel_model._meta.db_table),
+ 'to_field': self.quote(field.rel_model._meta.primary_key.db_column),
'cascade': ' ON DELETE CASCADE' if field.cascade else '',
}

0 comments on commit f4aae76

Please sign in to comment.