Skip to content

How to refresh a component from another component ? #730

@CedricRaison

Description

@CedricRaison

I have a ListPostView component which list my posts.

class ListPostView(UnicornView):
    posts = []

    def mount(self):
        self.posts = list(Post.objects.all().order_by('-created_at'))

I have another component which is a form to create a new post.

I would like after saving a new post to refresh my ListPostView to display my new post.

class CreatePostView(UnicornView):
    content = ""

    def save(self):
        if self.content:
            post = Post.objects.create(content=self.content)
            self.content = ""
            # refresh ListPostView so it can show my new post.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions