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.
Source:stackexchange.com