2

Scenario

I have group of users interested in each others' activity. Whenever a user of this group sees a feed (record), or shows some activity (like, comment, star) and continues; then whenever the next user opens the app randomly and sees the feed or shows some activity (like, comment, star), so the app will lead the second user to the first user's footsteps until they ignore at least three feeds (records).

The best I could come up with is a ManyToManyField model inside itself. By this method I will be able to classify every record (feed) and add all it's related feeds back to the same model even without adding a new record.

Example:

  • Sam saw feed 1
  • then Sam saw feed 5
  • then Sam saw feed 10
  • now it will add feed 5 and 10 as inner_feed to feed 1 and feed 10 to 5

Is something like this model possible in django?

class NewsFeed(models.Model):
    id = models.AutoField(primary_key=True)
    user  = models.ForeignKey(User, models.DO_NOTHING, related_name="feeduser")
    date_created = models.DateTimeField(default=timezone.now)
    last_update = models.DateTimeField(default=timezone.now)
    inner_feed = models.ManyToManyField(NewsFeed)
Community
  • 1
  • 1
Naqib Hakimi
  • 874
  • 4
  • 15
  • 2
    Yes, it's possible. Duplicate of [Django Many-to-Many (m2m) Relation to same model](https://stackoverflow.com/questions/11721157/django-many-to-many-m2m-relation-to-same-model) – solarissmoke Dec 15 '17 at 02:22

0 Answers0