I have a post model and a comment model that holds the comments that were made for a particular post.
class Post(models.Model):
body = models.TextField()
user = models.ForeignKey(User)
class Comment(models.Model):
post = models.ForeignKey(Post)
date = models.DateTimeField(auto_now_add=True)
comment = models.TextField()
comment_user = models.ForeignKey(User)
Now I want my Post resource to include URI to all the comments attached to a particular post.
I do know I can use fields.ForeignKey
to represent which post my comments belong to, but I want the API to have the URI of all the comments that belong to the post in the post object. I hope that makes sense.