Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force rendering parent doesn't run context processors #687

Open
denniseigner opened this issue Apr 9, 2024 · 0 comments
Open

Force rendering parent doesn't run context processors #687

denniseigner opened this issue Apr 9, 2024 · 0 comments

Comments

@denniseigner
Copy link

Hi,

I found a case when using nested components re-rendering the parent does not run context processors properly.

I set up a minimal project here: https://github.com/denniseigner/django-unicorn-example

python version: 3.10.12
Django version: 4.2.10
django-unicorn version: 0.60.0

The interesting parts are the following:

djangoapp/context_processors/my_flag.py

from django.conf import settings


def my_flag(request):
    return {"MY_FLAG": settings.MY_FLAG}

nested/templates/unicorn/overview.html

{% load unicorn %}

<div>
    {% if MY_FLAG %}
        Flag
    {% else %}
        NoFlag
    {% endif %}
    {% unicorn 'list-implementation' list_items=list_items %}
</div>

nested/components/list_filter.py

from django_unicorn.components import UnicornView


class ListFilterView(UnicornView):
    search = ""

    def updated_search(self, query):
        self.parent.parent.load_items(query)
        self.parent.parent.force_render = True

When updated_search gets called, MY_FLAG gets unset and NoFlag will be displayed on the overview page.

Is this intended behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant