{ "info": { "author": "Tomasz Jakub Rup", "author_email": "tomasz.rup@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Framework :: Django :: 1.4", "Framework :: Django :: 1.5", "Framework :: Django :: 1.6", "Framework :: Django :: 1.7", "Framework :: Django :: 1.8", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: PL/SQL", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "==================\ndjango-extra-tools\n==================\n\n.. image:: https://travis-ci.org/tomi77/django-extra-tools.svg?branch=master\n :target: https://travis-ci.org/tomi77/django-extra-tools\n.. image:: https://coveralls.io/repos/github/tomi77/django-extra-tools/badge.svg\n :target: https://coveralls.io/github/tomi77/django-extra-tools?branch=master\n.. image:: https://codeclimate.com/github/tomi77/django-extra-tools/badges/gpa.svg\n :target: https://codeclimate.com/github/tomi77/django-extra-tools\n :alt: Code Climate\n\nInstallation\n============\n\n.. sourcecode:: sh\n\n pip install django-extra-tools\n\nQuick start\n===========\n\nEnable ``django-extra-tools``\n\n.. sourcecode:: python\n\n INSTALLED_APPS = [\n ...\n 'django_extra_tools',\n ]\n\nInstall SQL functions\n\n.. sourcecode:: sh\n\n python manage.py migrate\n\nStringAgg aggregate function on Django 1.4 needs monkey patch\n\n.. sourcecode:: python\n\n from django_extra_tools.monkey import patch_django\n\n patch_all()\n\nTemplate filters\n================\n\nparse_datetime\n--------------\n\nParse datetime from string.\n\n.. sourcecode:: htmldjango\n\n {% load parse %}\n\n {{ string_datetime|parse_datetime|date:\"Y-m-d H:i\" }}\n\nparse_date\n----------\n\nParse date from string.\n\n.. sourcecode:: htmldjango\n\n {% load parse %}\n\n {{ string_date|parse_date|date:\"Y-m-d\" }}\n\nparse_time\n----------\n\nParse time from string.\n\n.. sourcecode:: htmldjango\n\n {% load parse %}\n\n {{ string_time|parse_time|date:\"H:i\" }}\n\nparse_duration\n--------------\n\nParse duration (timedelta) from string.\n\n.. sourcecode:: htmldjango\n\n {% load parse %}\n\n {{ string_duration|parse_duration }}\n\nAggregation\n===========\n\nFirst\n-----\n\nReturns the first non-NULL item.\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models.aggregates import First\n\n Table.objects.aggregate(First('col1', order_by='col2'))\n\nLast\n----\n\nReturns the last non-NULL item.\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models.aggregates import Last\n\n Table.objects.aggregate(Last('col1', order_by='col2'))\n\nMedian\n------\n\nReturns median value.\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models.aggregates import Median\n\n Table.objects.aggregate(Median('col1'))\n\nStringAgg\n---------\n\nCombines the values as the text. Fields are separated by a \"separator\".\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models.aggregates import StringAgg\n\n Table.objects.aggregate(StringAgg('col1'))\n\nModel mixins\n============\n\nCreatedAtMixin\n--------------\n\nAdd ``created_at`` field to model.\n\n.. sourcecode:: python\n\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.CreatedAtMixin, models.Model):\n pass\n\n model = MyModel()\n print(model.created_at)\n\nCreatedByMixin\n--------------\n\nAdd ``created_by`` field to model.\n\n.. sourcecode:: python\n\n from django.contrib.auth.models import User\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.CreatedByMixin, models.Model):\n pass\n\n user = User.objects.get(username='user')\n model = MyModel(created_by=user)\n print(model.created_by)\n\nUpdatedAtMixin\n--------------\n\nAdd ``updated_at`` field to model.\n\n.. sourcecode:: python\n\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.UpdatedAtMixin, models.Model):\n operation = models.CharField(max_length=10)\n\n model = MyModel()\n print(model.updated_at)\n model.operation = 'update'\n model.save()\n print(model.updated_at)\n\nUpdatedByMixin\n--------------\n\nAdd ``updated_by`` field to model.\n\n.. sourcecode:: python\n\n from django.contrib.auth.models import User\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.UpdatedByMixin, models.Model):\n operation = models.CharField(max_length=10)\n\n user = User.objects.get(username='user')\n model = MyModel()\n print(model.updated_by)\n model.operation = 'update'\n model.save_by(user)\n print(model.updated_by)\n\nDeletedAtMixin\n--------------\n\nAdd ``deleted_at`` field to model.\n\n.. sourcecode:: python\n\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.DeletedAtMixin, models.Model):\n pass\n\n model = MyModel()\n print(model.deleted_at)\n model.delete()\n print(model.deleted_at)\n\nDeletedByMixin\n--------------\n\nAdd ``deleted_by`` field to model.\n\n.. sourcecode:: python\n\n from django.contrib.auth.models import User\n from django.db import models\n from django_extra_tools.db.models import timestampable\n\n class MyModel(timestampable.DeletedByMixin, models.Model):\n pass\n\n user = User.objects.get(username='user')\n model = MyModel()\n print(model.deleted_by)\n model.delete_by(user)\n print(model.deleted_by)\n\nCreatedMixin\n------------\n\nAdd ``created_at`` and ``created_by`` fields to model.\n\nUpdatedMixin\n------------\n\nAdd ``updated_at`` and ``updated_by`` fields to model.\n\nDeletedMixin\n------------\n\nAdd ``deleted_at`` and ``deleted_by`` fields to model.\n\nDatabase functions\n==================\n\nbatch_qs\n--------\n\nReturns a (start, end, total, queryset) tuple for each batch in the given queryset.\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models import batch_qs\n\n qs = Table.objects.all()\n start, end, total, queryset = batch_qs(qs, 10)\n\npg_version\n----------\n\nReturn tuple with PostgreSQL version of a specific connection.\n\n.. sourcecode:: python\n\n from django_extra_tools.db.models import pg_version\n\n version = pg_version()\n\nHTTP Response\n=============\n\nHttpResponseGetFile\n-------------------\n\nAn HTTP response class with the \"download file\" headers.\n\n.. sourcecode:: python\n\n from django_extra_tools.http import HttpResponseGetFile\n\n return HttpResponseGetFile(filename='file.txt', content=b'file content', content_type='file/text')\n\nWSGI Request\n============\n\nget_client_ip\n-------------\n\nGet the client IP from the request.\n\n.. sourcecode:: python\n\n from django_extra_tools.wsgi_request import get_client_ip\n\n ip = get_client_ip(request)\n\nManagement\n==========\n\nOneInstanceCommand\n------------------\n\nA management command which will be run only one instance of command with\nname ``name``. No other command with name ``name`` can not be run in the\nsame time.\n\n.. sourcecode:: python\n\n from django_extra_tools.management import OneInstanceCommand\n\n class Command(OneInstanceCommand):\n name = 'mycommand'\n\n def handle_instance(self, *args, **options):\n # some operations\n\nNagiosCheckCommand\n------------------\n\nA management command which perform a Nagios check.\n\n.. sourcecode:: python\n\n from django_extra_tools.management import NagiosCheckCommand\n\n class Command(NagiosCheckCommand):\n def handle_nagios_check(self, *args, **options):\n return self.STATE_OK, 'OK'\n\nMiddleware\n==========\n\nXhrMiddleware\n-------------\n\nThis middleware allows cross-domain XHR using the html5 postMessage API.\n\n.. sourcecode:: python\n\n MIDDLEWARE_CLASSES = (\n ...\n 'django_extra_tools.middleware.XhrMiddleware'\n )\n\n XHR_MIDDLEWARE_ALLOWED_ORIGINS = '*'\n XHR_MIDDLEWARE_ALLOWED_METHODS = ['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE']\n XHR_MIDDLEWARE_ALLOWED_HEADERS = ['Content-Type', 'Authorization', 'Location', '*']\n XHR_MIDDLEWARE_ALLOWED_CREDENTIALS = 'true'\n XHR_MIDDLEWARE_EXPOSE_HEADERS = ['Location']\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tomi77/django-extra-tools", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-extra-tools", "package_url": "https://pypi.org/project/django-extra-tools/", "platform": "", "project_url": "https://pypi.org/project/django-extra-tools/", "project_urls": { "Homepage": "https://github.com/tomi77/django-extra-tools" }, "release_url": "https://pypi.org/project/django-extra-tools/0.3.0/", "requires_dist": null, "requires_python": "", "summary": "A set of functions related with Django", "version": "0.3.0" }, "last_serial": 2845874, "releases": { "0.1.0b2": [ { "comment_text": "", "digests": { "md5": "ee06dc8299aa682de3ac9b001dd894b0", "sha256": "bf795424a01eadd09826e0e74d18df244ecb8a76066c20cbc8d0fb711663ccf5" }, "downloads": -1, "filename": "django_extra_tools-0.1.0b2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ee06dc8299aa682de3ac9b001dd894b0", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 21487, "upload_time": "2016-09-21T20:00:56", "url": "https://files.pythonhosted.org/packages/f2/ff/30210e22178c9b731581052fe8b02a1a518f867db68924e8f0739de87494/django_extra_tools-0.1.0b2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f2c6441a6e897abbf944206370b63753", "sha256": "dba9214f2621de900af28f11825c0249a7da5779142248824d6c61967f6776e6" }, "downloads": -1, "filename": "django-extra-tools-0.1.0b2.tar.gz", "has_sig": false, "md5_digest": "f2c6441a6e897abbf944206370b63753", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8313, "upload_time": "2016-09-21T20:00:27", "url": "https://files.pythonhosted.org/packages/95/06/e792e02d299455d7b56ab5b0a4089973061b7260c8bc365e39fd585c3f1e/django-extra-tools-0.1.0b2.tar.gz" } ], "0.2.0b1": [ { "comment_text": "", "digests": { "md5": "d257126b792b51ab9d7ba37f97c51227", "sha256": "de30ce2948572920f0eea46c7520b0dcf8a94c5cbe4bb9a22e5f0c8752bd623c" }, "downloads": -1, "filename": "django_extra_tools-0.2.0b1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d257126b792b51ab9d7ba37f97c51227", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 22725, "upload_time": "2016-09-23T07:26:41", "url": "https://files.pythonhosted.org/packages/68/d7/27349261bd0423cf8c2f6a699440659cc4588b58e5b7bbc5e5537c91e286/django_extra_tools-0.2.0b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2097edb06e1510f286536467c735ecd", "sha256": "cf425e857cc7d15384cac400a055f26f8fd3e3d83fa0dc410736736fd483083e" }, "downloads": -1, "filename": "django-extra-tools-0.2.0b1.tar.gz", "has_sig": false, "md5_digest": "c2097edb06e1510f286536467c735ecd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9123, "upload_time": "2016-09-23T07:26:38", "url": "https://files.pythonhosted.org/packages/23/fd/4868c3d84cee9d3d53e2395b64aa4733b934e822e30b1313630c1309b353/django-extra-tools-0.2.0b1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "29e147c661cfb0d2f87d7d68ef0ee433", "sha256": "b2b1b918912d8f62a1f560b5760057189e17ebeb18410cf8620599f0330fad67" }, "downloads": -1, "filename": "django_extra_tools-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "29e147c661cfb0d2f87d7d68ef0ee433", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 18583, "upload_time": "2017-05-02T08:28:12", "url": "https://files.pythonhosted.org/packages/4b/6c/1052df17e91625a563d9855adfd5335eac774927a3357e21b671101d5470/django_extra_tools-0.3.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "29e147c661cfb0d2f87d7d68ef0ee433", "sha256": "b2b1b918912d8f62a1f560b5760057189e17ebeb18410cf8620599f0330fad67" }, "downloads": -1, "filename": "django_extra_tools-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "29e147c661cfb0d2f87d7d68ef0ee433", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 18583, "upload_time": "2017-05-02T08:28:12", "url": "https://files.pythonhosted.org/packages/4b/6c/1052df17e91625a563d9855adfd5335eac774927a3357e21b671101d5470/django_extra_tools-0.3.0-py2.py3-none-any.whl" } ] }