question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TemplateNotFound errors when the same context is passed to django_render_block multiple times

See original GitHub issue

As of 0.8, django_render_block(...) was modified to preserve the original context object if it had the type django.template.Context. Unfortunately, context objects are mutable and this has resulted in odd behaviour if django_render_block is called multiple times with the same context object. In our case, we started seeing TemplateNotFound errors because Django’s templating engine skipped templates it thought it had already parsed.

This is a somewhat urgent issue, because django-templated-email has an unpinned dependency on django-render-block and calls django_render_block multiple times with the same context: https://github.com/vintasoftware/django-templated-email/blob/cba05a7b0f355acdc18174acd1ae468ad77e023d/templated_email/backends/vanilla_django.py#L106

The solution should be as simple as making a deep copy of the context object instead of using it directly.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
evanbrumleycommented, Oct 16, 2020

No problems! Thank you for taking the time to maintain such a useful library 😃

1reaction
clokepcommented, Oct 15, 2020

I just pushed 0.8.1 which includes the fix. Thanks so much! 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flask raises TemplateNotFound error even though template ...
The error indicates that there is no home.html file in the templates/ directory. Make sure you created that directory in the same directory ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found