[Django]-What is the best way to include Mercurial changeset id (or revision) in a Django template?


See: KeywordPlan

In your release-to-production process, use hg id to get the current version information from Mercurial. You can easily stash that in a file that you then include in your Django templates.

For example, in whatever script/process you use at release time, do:

hg id >templates/id.html

And then at the bottom in your main Django template (or wherever), add:

Revision:  {{ include "templates/id.html" }}

(NOTE: the paths/directories may vary depending on how you have your template paths configured in Django).


Leave a comment