======================
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": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"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/db/f5/9fd9f7426bf5175d8e056d4cb6bc8a289c9015f23daa00ebaae74172d068/dj_static_revision-0.7.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.7",
"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": "0681bd524da0bbd8e4796f430416a2373e997832ca5d7dc9df4811dd4b18cee7",
"md5": "5e39d71aff61baf9a460d9c27cdae68e",
"sha256": "3f0a0fe0890522c6625ccf497490e07c164de1879dd5f7a52c2961c9df93fa4f"
},
"downloads": -1,
"filename": "dj_static_revision-0.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5e39d71aff61baf9a460d9c27cdae68e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 3714,
"upload_time": "2024-05-23T11:43:39",
"upload_time_iso_8601": "2024-05-23T11:43:39.221921Z",
"url": "https://files.pythonhosted.org/packages/06/81/bd524da0bbd8e4796f430416a2373e997832ca5d7dc9df4811dd4b18cee7/dj_static_revision-0.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dbf59fd9f7426bf5175d8e056d4cb6bc8a289c9015f23daa00ebaae74172d068",
"md5": "d457e49e6b541d388731079ddfaea11d",
"sha256": "45ff9c59d9159bc9ec3d9add3093d4f3d4fdbf60da784ab5ce37662b221b7735"
},
"downloads": -1,
"filename": "dj_static_revision-0.7.tar.gz",
"has_sig": false,
"md5_digest": "d457e49e6b541d388731079ddfaea11d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 3151,
"upload_time": "2024-05-23T11:43:40",
"upload_time_iso_8601": "2024-05-23T11:43:40.640935Z",
"url": "https://files.pythonhosted.org/packages/db/f5/9fd9f7426bf5175d8e056d4cb6bc8a289c9015f23daa00ebaae74172d068/dj_static_revision-0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-23 11:43:40",
"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"
}