[Answer]-Commenting app for all other apps in Django

1👍

Have you thought about adding a ForeignKey class Comment in your models.py?

The model is pretty straightforward:

class Comment(models.Model):
     *attached_to* = models.ForeignKey(CONTENT)
     body = models.TextField()
     parent = models.ForeignKey('self', related_name="children")

other fields...

Will you be using the same comments for each type of content or do you want unique behavior for each type of content?

For one app, the above model is the simplest.

For multiple apps, you’re better off – I think – breaking out Comments into an independent app which call on the appropriate apps in the ForeignKey (Foreign key from one app into another in Django)

If you’re looking for a universal comment system, the above model will work, but you’ll likely want to check out GenericForeignKey (Django Model field with multiple types?).

👤Craig

Leave a comment