[Fixed]-Calling an instance of same class inside class

1👍

Use a ManyToManyField with the argument 'self'.

class Student(models.Model):
  name = models.CharField(max_length=128, unique=True)
  friends = models.ManyToManyField('self', blank = True)

You may wish to consider if the relationship is symmetrical.

Leave a comment