Skip to content

Instantly share code, notes, and snippets.

@carlosrberto
Created March 1, 2012 13:32
Show Gist options
  • Save carlosrberto/1949838 to your computer and use it in GitHub Desktop.
Save carlosrberto/1949838 to your computer and use it in GitHub Desktop.
django template revision number
import os
from django import template
from django.utils import version
from settings import PROJECT_PATH
STATIC_PATH = os.path.join(PROJECT_PATH, '../static')
register = template.Library()
@register.simple_tag
def revision_number():
rev = version.get_svn_revision(STATIC_PATH)
return rev.split('-')[1]
{% load svn_revision %}
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>title</title>
<link rel="stylesheet" href="path/to/file.css?rev={% revision_number %}" />
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment