So I'm building out a database where I need to have a field related to a specific ManyToMany relationship, but I don't know how to translate this into the Django ORM. For example, I have multiple Articles that can go with multiple Publications, but I want to see which article got the most views.
I figure that I could build the database like so:
+------------+--------+--------+-------+
| art_pub_id | art_id | pub_id | views |
+------------+--------+--------+-------+
| 101 | 201 | 301 | 6 |
+------------+--------+--------+-------+
| 102 | 201 | 302 | 4 |
+------------+--------+--------+-------+
| 103 | 202 | 301 | 8 |
+------------+--------+--------+-------+
Or I could do this
+------------+--------+--------+
| art_pub_id | art_id | pub_id |
+------------+--------+--------+
| 101 | 201 | 301 |
+------------+--------+--------+
| 102 | 201 | 302 |
+------------+--------+--------+
| 103 | 202 | 301 |
+------------+--------+--------+
+----+------------+-------+
| pk | art_pub_id | views |
+----+------------+-------+
| 1 | 101 | 6 |
+----+------------+-------+
| 2 | 102 | 4 |
+----+------------+-------+
| 3 | 103 | 8 |
+----+------------+-------+
I'm struggling with how to translate this to the Django ORM. I have the Article with the ManyToManyField pointing to the Publication, but I don't know where or how to place the views IntegerField. I have tried having a Publication_Article class that has two ManyToMany fields and my views field, but I'm not sure that is the right way to be doing it.
I also fully recognize that I may be approaching the problem wrong with my database design, in which case knowing the best way to do this would be invaluable for me.