[Answer]-Database model for user subscriptions

1👍

You are looking for ManyToManyField, which is Django way to create N-N tables.

class Topic(models.Model):
    name = ...

class Article(models.Model):
    content = ...
    topics = models.ManyToManyField(Topic)

In the background, Django will create a new table to link Topic and Article because you can’t have a N-N table in SQL.

👤Nil

Leave a comment