mirror of
https://github.com/django-components/django-components.git
synced 2025-08-09 08:48:00 +00:00
fix: TemplateDoesNotExist when using {% extends %} on main template and two components with same parent template (#862)
This commit is contained in:
parent
6bb73bd8af
commit
85fc6e3497
9 changed files with 876 additions and 394 deletions
|
@ -692,6 +692,10 @@ class Component(
|
|||
if not isinstance(context, Context):
|
||||
context = RequestContext(request, context) if request else Context(context)
|
||||
|
||||
# Required for compatibility with Django's {% extends %} tag
|
||||
# See https://github.com/EmilStenstrom/django-components/pull/859
|
||||
context.render_context.push({BLOCK_CONTEXT_KEY: context.render_context.get(BLOCK_CONTEXT_KEY, {})})
|
||||
|
||||
# By adding the current input to the stack, we temporarily allow users
|
||||
# to access the provided context, slots, etc. Also required so users can
|
||||
# call `self.inject()` from within `get_context_data()`.
|
||||
|
@ -768,6 +772,7 @@ class Component(
|
|||
# After rendering is done, remove the current state from the stack, which means
|
||||
# properties like `self.context` will no longer return the current state.
|
||||
self._render_stack.pop()
|
||||
context.render_context.pop()
|
||||
|
||||
return output
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue