Suddenly I am getting an error saying TypeError: on_delete must be callable.
I don't know how to solve this error as I don't see field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category'),
mentioned anywhere in my code.
File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 6, in <module>
class Migration(migrations.Migration):
File "/home/arch/myproject/main/migrations/0014_auto_20191025_1154.py", line 47, in Migration
field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category'),
File "/home/arch/.local/lib/python3.8/site-packages/django/db/models/fields/related.py", line 801, in __init__
raise TypeError('on_delete must be callable.')
TypeError: on_delete must be callable.
A field in one of your models has:
class SomeModel(models.Model):
# …
field=models.ForeignKey(default=1, on_delete='CASCADE', to='main.Category')
but you can not pass a string to on_delete=…
parameter, it should be:
class SomeModel(models.Model):
# …
field=models.ForeignKey(default=1, on_delete=models.CASCADE, to='main.Category')
You will need to remove the migration file (main/migrations/0014_auto_20191025_1154.py
) as well, and make new migrations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With