Skip to content

Templating related Activity models #19

@Zonalds

Description

@Zonalds

I have two related models in Django models by a foreignkey. A post model and a comment model. They would look like:

```

from stream_django.activity import Activity

class UserPost(models.Model, Activity):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='userPost')
    title = models.CharField(max_length=30)
    content = models.CharField(max_length=300)
    created_at = models.DateTimeField(auto_now_add=True)

/the userpost comment would look something like:

class PostComment(models.Model, Activity):
    post = models.ForeignKey(UserPost, on_delete=models.CASCADE, related_name='postcomment')
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='post_comment_user')
    comment = models.TextField(max_length=1000, blank=True, null=True)
    created_at = models.DateTimeField(auto_now_add=True)

.
I can template either the UserPost or just the PostComment Activity but somehow can't find a way to template both in a way that they can can reference each other. Sort of PostComment right under the UserPost it references. Any help with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions