We can easily create relationships between our models w/ django's built-in model fields
this is useful as we expand the functionality of our web app to include more complex features
class UserModel(AbstractUser):
class Meta:
db_table = "my_user"
bio = models.CharField(max_length=256, default='')
follow = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='followee')
For example, we can create dynamic templates for a follow/unfollow feature:
{% if ul in user.follow.all %}
<a href="/user/follow/{{ ul.id }}" class="card-link">[팔로우 취소]</a>
{% else %}
<a href="/user/follow/{{ ul.id }}" class="card-link">[팔로우]</a>
{% endif %}