
장고 팔로우, 팔로잉 기능 구현하기
2022. 10. 13. 17:22
Django 개념
커스텀 user앱 --> accounts accounts/models.py from django.db import models from django.contrib.auth.models import AbstractUser # Create your models here. class User(AbstractUser): followings = models.ManyToManyField('self', symmetrical=False, related_name='followers') 커스텀 유저앱 models.py에 User로 커스텀한 클래스에 followings 필드 추가 필드는 ManyToManyField, 첫 매개변수는 'self', symmetrical은 False (True로 하면 서로 맞팔이 자동으로 됨) ..