How do I get the mercurial version in a django app?
I'd like to use the 开发者_运维问答working directory's mercurial version info within a Django app. By version info, I really mean <changeset, branch, and tag>
.
Are there plugins or techniques to do this?
I've got one way implemented in settings.py, but I haven't found a way I like to make these data available to code and templates. Any ideas?
I am aware of related techniques to write version info to a file or template, and that's not what I'm looking for. Instead, I want version info in a variable within the Django app.
Environment: Ubuntu 11.04, virtualenv, Python 2.7, Django 1.3, Mercurial 1.9.x.
Thanks!
What's the problem? If you have e.g. HG_REV
variable in settings
module, you can access it from the rest of the code via django.conf.settings
proxy, like any other setting. If you want to expose it to every template, then the easiest way is to write a context processor.
精彩评论