Reputation: 11686
when i create a model with a foreign key relationship, something like this:
class Post(models.Model):
title = models.CharField(max_length=250)
date_created = models.DateTimeField(auto_now=False, auto_now_add=True)
owner = models.ForeignKey(User)
when i do syncdb to dump those models to the DB it creates the table post
and a foreign key to the table user
. How can avoid the creation of that Foreign Key in MySQL. I hate foreign keys for different reasons.
Thank you!
EDIT:
Please guys, don't answer: "You should use foreign keys". That's not what i'm asking. I've my reasons not to use them.
Upvotes: 0
Views: 244
Reputation: 2769
Please don't. Foreign keys are the right thing to have and you should never prevent the database from protecting its own consistency. If you need to do something special to the table (and are sure not to break its integrity) you can temporarily disable the checks:
SET foreign_key_checks = 0
# do something
SET foreign_key_checks = 1
Upvotes: 2