Reputation: 85
I'm trying to migrate some model classes to the built-in Django SQL database admin, but I'm getting a TypeError
when I try to migrate. What am I doing wrong?
Upvotes: 0
Views: 59
Reputation: 1291
Welcome to stackoverflow!
Whenever you declare a foreign key in Django models, you are required to define what Django should do if the referenced entity is deleted.
According to Django documentation:
A many-to-one relationship. Requires two positional arguments: the class to which the model is related and the on_delete option.
You can read more about it here Django Official Documentation
To solve your problem simply add a on_delete attribute to your foreign keys like:
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
Upvotes: 1
Reputation: 156
looks like it required "on_delete" arg, try with:
line 16: topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
Upvotes: 0