dj-static-revision


Namedj-static-revision JSON
Version 0.6 PyPI version JSON
download
home_pagehttps://github.com/AgriConnect/dj-static-revision
SummaryRevision info for Django static file
upload_time2023-07-19 11:00:34
maintainer
docs_urlNone
authorNguyễn Hồng Quân
requires_python>=3.8,<4.0
licenseApache-2.0
keywords django static version cache
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======================
Django Static Revision
======================

.. image:: https://madewithlove.now.sh/vn?heart=true&colorA=%23ffcd00&colorB=%23da251d
.. image:: https://badgen.net/pypi/v/dj-static-revision
   :target: https://pypi.org/project/dj-static-revision


Django plugin to provide a context variable for retrieving the version of running application.

This variable is meant to change the URL of a static file, to invalidate browser cache.


Install
-------

.. code-block:: shell

    pip3 install dj-static-revision

`Django Static Revision` only supports Python 3.8+.


Usage
-----

Add ``dj_static_revision.context_processors.static_revision`` to your ``context_processors`` list.

.. code-block:: python

    TEMPLATES = (
        {
            'NAME': 'jinja2',
            'BACKEND': 'django_jinja.backend.Jinja2',
            'OPTIONS': {
                'context_processors': (
                    # Other context processors
                    'dj_static_revision.context_processors.static_revision',
                ),

A variable ``REVISION`` will then exists in your template, you can use it to append to static file URL.

.. code-block:: jinja

    <script src="{{ static('js/app.js') }}?v={{ REVISION }}"></script>


`Django Static Revision` retrieves revision string from Git history.
If your source code is not managed by Git, the revision info will be read from a file named `.version` placed next to `manage.py` file.


Settings
--------

The revision string will be truncated to 10 characters. You can change that by add to Django settings:

.. code-block:: python

    STATIC_REVISION_STRING_LENGTH = 10

You can also change the file for `Django Static Revision` to read revision string from, by add this setting:

.. code-block:: python

    STATIC_REVISION_VERSION_FILE = '.version'

where *.version* is a text file containing any string you want.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AgriConnect/dj-static-revision",
    "name": "dj-static-revision",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "django,static,version,cache",
    "author": "Nguy\u1ec5n H\u1ed3ng Qu\u00e2n",
    "author_email": "ng.hong.quan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7f/4b/82ce1d8d59f758278c0e7907a566089e6f8ad53274673dc61bc606e91508/dj_static_revision-0.6.tar.gz",
    "platform": null,
    "description": "======================\nDjango Static Revision\n======================\n\n.. image:: https://madewithlove.now.sh/vn?heart=true&colorA=%23ffcd00&colorB=%23da251d\n.. image:: https://badgen.net/pypi/v/dj-static-revision\n   :target: https://pypi.org/project/dj-static-revision\n\n\nDjango plugin to provide a context variable for retrieving the version of running application.\n\nThis variable is meant to change the URL of a static file, to invalidate browser cache.\n\n\nInstall\n-------\n\n.. code-block:: shell\n\n    pip3 install dj-static-revision\n\n`Django Static Revision` only supports Python 3.8+.\n\n\nUsage\n-----\n\nAdd ``dj_static_revision.context_processors.static_revision`` to your ``context_processors`` list.\n\n.. code-block:: python\n\n    TEMPLATES = (\n        {\n            'NAME': 'jinja2',\n            'BACKEND': 'django_jinja.backend.Jinja2',\n            'OPTIONS': {\n                'context_processors': (\n                    # Other context processors\n                    'dj_static_revision.context_processors.static_revision',\n                ),\n\nA variable ``REVISION`` will then exists in your template, you can use it to append to static file URL.\n\n.. code-block:: jinja\n\n    <script src=\"{{ static('js/app.js') }}?v={{ REVISION }}\"></script>\n\n\n`Django Static Revision` retrieves revision string from Git history.\nIf your source code is not managed by Git, the revision info will be read from a file named `.version` placed next to `manage.py` file.\n\n\nSettings\n--------\n\nThe revision string will be truncated to 10 characters. You can change that by add to Django settings:\n\n.. code-block:: python\n\n    STATIC_REVISION_STRING_LENGTH = 10\n\nYou can also change the file for `Django Static Revision` to read revision string from, by add this setting:\n\n.. code-block:: python\n\n    STATIC_REVISION_VERSION_FILE = '.version'\n\nwhere *.version* is a text file containing any string you want.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Revision info for Django static file",
    "version": "0.6",
    "project_urls": {
        "Homepage": "https://github.com/AgriConnect/dj-static-revision",
        "Repository": "https://github.com/AgriConnect/dj-static-revision.git"
    },
    "split_keywords": [
        "django",
        "static",
        "version",
        "cache"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f72fc6523fb0ce54ab34eeaa8728389bb078ecc12a103f822f571601501a453a",
                "md5": "087477c359528df22268a9743ce1fbe1",
                "sha256": "315dd3cf8464baa4ab2f5f868566f48047facb50f0c34d8aebbebee186ffe0dd"
            },
            "downloads": -1,
            "filename": "dj_static_revision-0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "087477c359528df22268a9743ce1fbe1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 3710,
            "upload_time": "2023-07-19T11:00:33",
            "upload_time_iso_8601": "2023-07-19T11:00:33.216277Z",
            "url": "https://files.pythonhosted.org/packages/f7/2f/c6523fb0ce54ab34eeaa8728389bb078ecc12a103f822f571601501a453a/dj_static_revision-0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f4b82ce1d8d59f758278c0e7907a566089e6f8ad53274673dc61bc606e91508",
                "md5": "1e94a0a9d96ac00136a8b7cbc3b27205",
                "sha256": "50dc3326df39a00441d27334dec1bc89dbd56ff14b9692bef46c4d3e878f29bf"
            },
            "downloads": -1,
            "filename": "dj_static_revision-0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "1e94a0a9d96ac00136a8b7cbc3b27205",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 3088,
            "upload_time": "2023-07-19T11:00:34",
            "upload_time_iso_8601": "2023-07-19T11:00:34.863548Z",
            "url": "https://files.pythonhosted.org/packages/7f/4b/82ce1d8d59f758278c0e7907a566089e6f8ad53274673dc61bc606e91508/dj_static_revision-0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-19 11:00:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AgriConnect",
    "github_project": "dj-static-revision",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "dj-static-revision"
}
        
Elapsed time: 0.17509s