I'm trying to make a 'friendlist' function in django models and I'm having some problems. In my app, every user can make a name card. I want to let the users add each others as 'friends'(just like fb), so that I can make a friendlist for them.
This is what my models.py looks like so far.
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Card(models.Model):
owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="cards")
# friend_list = models.????
I'd like to add a 'friend_list' attribute, which can store other cards' informations(I'm thinking of their pk values). Later, I'd like to iterate those values so that I can use it to make a friendlist in the template.
For example, "George's name card" should have information of its friends' cards' pk value.
Is there a way to save multiple values in one attribute?