Answer the question
In order to leave comments, you need to log in
How to implement adding to friends?
from django.db import models
from django.contrib.auth.models import User
class Friend(models.Model):
class Meta:
db_table = 'Friend'
user = models.ForeignKey(User)
friend = models.ForeignKey(User, related_name="friends")
date = models.DateTimeField(auto_now_add=True)
Answer the question
In order to leave comments, you need to log in
Alternatively, something like this:
class User(models.Model):
...
friends = models.ManyToManyField("self", blank=True)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question