I am new to Django and Python. I have created some models in Django, and now can no longer run the application because of the following error:
"TypeError: CASCADE() missing 4 required positional arguments: 'collector', 'field', 'sub_objs', and 'using'"
Here is the model code:
class Lifter(models.Model):
name = models.CharField(max_length=250)
age = models.IntegerField(max_length=100);
gender = models.CharField(max_length=1);
person_photo = models.CharField(max_length=1000);
def __str__(self):
return self.name + ' - ' + self.gender
class Results(models.Model):
lifter = models.ForeignKey(Lifter, on_delete=models.CASCADE())
Any idea on what is wrong?
Thank you!
Just replace CASCADE()
with CASCADE
:
class Results(models.Model):
lifter = models.ForeignKey(Lifter, on_delete=models.CASCADE)
Example with ForeignKey from Django docs
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