django-project-version is a Django reusable app to show your project version
Contents
- Obtain your copy of source code from the git repository:
$ git clone https://github.com/DCOD-OpenSource/django-project-version.git. Or download the latest release from https://github.com/DCOD-OpenSource/django-project-version/tags/. - Run
$ python ./setup.py installfrom the repository source tree or unpacked archive. Or use pip:$ pip install django-project-version.
- Add
"djversion"tosettings.INSTALLED_APPS.
# settings.py
INSTALLED_APPS += [
"djversion",
]DJVERSION_VERSION- Contains project version. Defaults to
None. DJVERSION_UPDATED- Contains project update date or datetime. Defaults to
None. DJVERSION_FORMAT_STRING- Contains version and updated format string. Defaults to
"{version} ({updated})". DJVERSION_GIT_REPO_PATH- Contains path to git repository from where version info can get. Defaults to
None. DJVERSION_GIT_USE_TAG- Indicate usage of git repository current tag as project version. Defaults to
False. DJVERSION_GIT_USE_COMMIT- Indicate usage of git repository last commit hash as project version. Defaults to
False.
If you want always have "VERSION" variable in templates context, just add "djversion.context_processors.version" to settings.TEMPLATE_CONTEXT_PROCESSORS
# settings.py
TEMPLATE_CONTEXT_PROCESSORS += [
"djversion.context_processors.version",
]Or you can use project_version templatetag which can be loaded from djversion_tags.
{# footer.html #}
{% load djversion_tags %}
{% project_version as VERSION %}
{{ VERSION }}Also simple management command print-version which prints project version to stdout is available. Just run:
django-admin print-versionor
./manage.py print-versionIf you want to have REST-style view with your project version:
- Install
django-project-versionwith additional dependencies:$ pip install django-project-version[rest]. - Extend you
settings.INSTALLED_APPSby adding"rest_framework".
# settings.py
INSTALLED_APPS += [
"rest_framework",
]- Add
"djversion"to your URLs definitions:
# urls.py
from django.urls import re_path, include
urlpatterns += [
re_path(r"^version/", include("djversion.urls")),
]Or to use information from the project git repository as project version:
- Install
django-project-versionwith additional dependencies:$ pip install django-project-version[git]. - Configure git related settings.
- Fork it
- Install GNU Make
- Install and configure pyenv and pyenv-virtualenv plugin
- Install and configure direnv
- Create environment config from example
cp .env.example .env- Install development dependencies:
make install- Create your fix/feature branch:
git checkout -b my-new-fix-or-feature- Check code style and moreover:
make check- Run tests:
make test- Push to the branch:
git push origin my-new-fix-or-featuredjango-project-version uses the MIT license. Please check the MIT-LICENSE file for more details.
Project Website: https://github.com/DCOD-OpenSource/django-project-version/
Author: DCOD <[email protected]>
For contributors list see CONTRIBUTORS file.