Skip to main content

Django git revision, simple add current git revision to request object for use in tempaltes and views.

Project description

Django Git Revision is django application that allows use git last head commit hexstring in views and templates.

Requirements

  • python >= 2.5

  • django >= 1.2

  • gitpython

Installation

Django Git Revision should be installed using pip:

pip install django-gitrevision

Setup and use

  1. Add gitrevision to INSTALLED_APPS:

    INSTALLED_APPS += 'gitrevision',
  2. If you want use git revision only in templates add gitrevision context processor in settings:

    TEMPLATE_CONTEXT_PROCESSORS += 'gitrevision.context_processors.gitrevision',

    And use GIT_REVISION var in templates:

    ...
    <script src="/test.js?{{ GIT_REVISION }}"></script>
    ...
  3. Or if you want use git revision in views and templates, add gitrevision middleware in settings:

    MIDDLEWARE_CLASSES += 'gitrevision.middleware.GitRevision',

    Using in views:

    def superview( request ):
        git_revision = request.git_revision
        ...

    Using in templates (with requestcontext):

    ...
    <script src="/test.js?{{ request.git_revision }}"></script>
    ...
  4. Maybe you be needed append GIT_PATH in django settings:

    GIT_PATH = <path_to_your_git_repository>

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/django-gitrevision/issues

Contributing

Development of django-gitrevision happens at github: https://github.com/klen/django-gitrevision

Contributors

  • klen (Kirill Klenov)

License

Licensed under a GNU lesser general public license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-gitrevision-0.1.4.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file django-gitrevision-0.1.4.tar.gz.

File metadata

File hashes

Hashes for django-gitrevision-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8dca4621f180bb572aceb742ee81e9166dc6a2f8f35a262348c50564f3dadb78
MD5 ddac6fae63f5f38f11e1599d9f7ad9fd
BLAKE2b-256 ac861686b23a29bff028037244f84668ae1f5a0ab214de07334b0a2dd53517d6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page