Skip to content

Instantly share code, notes, and snippets.

@peterdemin
Last active September 13, 2018 18:09
Show Gist options
  • Save peterdemin/c2bfb9879c069b470598efbd8ca6621d to your computer and use it in GitHub Desktop.
Save peterdemin/c2bfb9879c069b470598efbd8ca6621d to your computer and use it in GitHub Desktop.
Django-TMS

Django Text Management System

Motivation

Django templates often contain text/media that doesn't affect application's functionality. These texts belong to product people, but because they are stored in template files, are modified by developers. Such editing is slow and continious delivery pipelines treat it the same way as code changes.

How things used to be

Product manager finds a typo on the landing page, he has to describe it to developer. Developer has to interrupt the flow and make a trivial change in the template and commit/push the fix. Build system runs all tests and eventually deploys corrected text to the test site. The manager reviews the fix and initiates deployment to production. Build system spins its wheel again and finally fixed typo lands on production site.

Same scenario with Django TMS

Product manager finds a typo on the landing page. He opens Django TMS interface and fixes it. He previews his change right there. He deploys the change to both testing and production.

Features

  • Support {% include "tms/intro.md" %} template syntax;
  • Render markdown files to Django templates on-the-go if DEBUG=True;
  • Render to HTML templates in django collectstatic;
  • Pack all rendered HTML templates into .tar.gz file;
  • Serve cached pre-rendered HTML template packs.

Installation

Install python package:

pip install django-tms

Add it to settings.py. INSTALLED_APPS, TEMPLATES, all that stuff.

Usage

Add templates/tms/ directory and put hello.md there:

# Hello, *world*!

Django-TMS is like a magic!

Inside regular template include the new snippet:

<html>
  <body>
    {% include "tms/hello.md" %}
  </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment