Save 37% off PRO during our Black Friday Sale! »

Using a custom template loader at scale

9da94e6b6107563a68d185a02137a32e?s=47 Dane Hillard
September 23, 2019

Using a custom template loader at scale

In the interest of team autonomy and fault tolerance, we partition parts of our platform into isolated Django projects. Although this allows for independent development work, it also means that some resources that are traditionally created on a per-project basis, like globally-used templates, need to be shared across projects. A reusable Django app could normally do the trick, but we want to deliver template updates to all consumers as instantaneously as possible without deployments. How do we do it?

9da94e6b6107563a68d185a02137a32e?s=128

Dane Hillard

September 23, 2019
Tweet

Transcript

  1. @easyaspython Using a custom template loader at scale Dane Hillard

    Lead Web Application Developer 1
  2. @easyaspython >>> help(Dane) 2

  3. @easyaspython Web: https://dane.dev Twitter: @easyaspython GitHub: @daneah 3

  4. @easyaspython 4

  5. @easyaspython 5

  6. @easyaspython 6

  7. @easyaspython 7

  8. @easyaspython 8

  9. @easyaspython 9

  10. @easyaspython 10

  11. @easyaspython Enter Django 11

  12. @easyaspython 12 Enter Django

  13. @easyaspython Django approach • Distinct Django projects ◦ For fault

    tolerance ◦ For independent performance profiling • A shared core of apps and packages ◦ Authentication ◦ Permissions ◦ Search form ◦ Look and feel 13
  14. @easyaspython 14 Template approach

  15. @easyaspython Changes to look and feel required deployment to every

    consumer 15
  16. @easyaspython This was Not Good® 16

  17. @easyaspython Desires • Consumers receive updates without deployment • In

    near-real time • Without affecting page load performance 17
  18. @easyaspython A service for templates? 18

  19. @easyaspython ✨ Custom template loader ✨ 19

  20. @easyaspython Custom template loader 20 • What is it? •

    How do we use it? • What did it get us? • What’s left?
  21. @easyaspython What is it? 21

  22. @easyaspython 22

  23. @easyaspython 23

  24. @easyaspython 24

  25. @easyaspython django.template.loaders: • filesystem.Loader • app_directories.Loader • cached.Loader 25

  26. @easyaspython 26

  27. @easyaspython 27

  28. @easyaspython How do we use it? 28

  29. @easyaspython 29 get_contents get_template_sources

  30. @easyaspython 30

  31. @easyaspython What did it get us? 31

  32. @easyaspython Desires • ✅ Consumers receive updates without deployment •

    ✅ In near-real time • ✅ Without affecting page load performance 32
  33. @easyaspython Per-user configuration for testing changes 33

  34. @easyaspython 34

  35. @easyaspython 35

  36. @easyaspython Demo 36

  37. @easyaspython Parallel development of a site-wide redesign 37

  38. @easyaspython Problems we faced 38

  39. @easyaspython The thundering herd 39

  40. @easyaspython cached.Loader configuration 40

  41. @easyaspython File management is clumsy 41

  42. @easyaspython What’s left? 42

  43. @easyaspython Improve adding/removing layouts, cleaning up old templates 43

  44. @easyaspython Leverage version control 44

  45. @easyaspython render( request, {“conf”: “DjangoCon US”}, “thanks.html”, ) 45