How does context in relation to django-components work? #226
-
When using a I assume that this is because then the component_block doesn't have the context of the template within the slot. But this feels like it should be possible. I wonder if this is a limitation of the framework, rather than the package? I really like enforcing the context that the component receives with parameters, but when it's a slot, it feels as if that's part of the template the block is placed in and should have the context, even when using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
@timothyis Thanks for the bug (I think) report. Could you show some sample code of how you use "only"? I don't think we have any tests related to the usage of only, so it's no surprise that this doesn't work as expected. |
Beta Was this translation helpful? Give feedback.
-
For anyone who comes across this thread, this has now been revamped in v0.70 (preferably use v0.72 or higher) We now support both of the approaches above, as described by @timothyis and @EmilStenstrom. For @timothyis's approach, in Django settings, set: COMPONENTS = {
"context_behavior": "isolated",
} For @EmilStenstrom's approach, in Django settings, set: COMPONENTS = {
"context_behavior": "django",
} For more info, see https://github.com/EmilStenstrom/django-components/blob/085c60a8c96442d9fd4f72d66a7eb295e7cfb2d9/README.md#context-behavior |
Beta Was this translation helpful? Give feedback.
For anyone who comes across this thread, this has now been revamped in v0.70 (preferably use v0.72 or higher)
We now support both of the approaches above, as described by @timothyis and @EmilStenstrom.
For @timothyis's approach, in Django settings, set:
For @EmilStenstrom's approach, in Django settings, set:
For more info, see https://github.com/EmilStenstrom/django-components/blob/085c60a8c96442d9fd4f72d66a7eb295e7cfb2d9/README.md#context-behavior