Name | django-utils2 JSON |
Version |
3.0.2
JSON |
| download |
home_page | https://github.com/WoLpH/django-utils |
Summary | Django Utils is a module with some convenient utilities not included with the standard Django install |
upload_time | 2023-10-13 19:29:10 |
maintainer | |
docs_url | https://pythonhosted.org/django-utils2/ |
author | Rick van Hattem |
requires_python | |
license | BSD |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
Introduction
============
Build status:
.. image:: https://github.com/WoLpH/django-utils/actions/workflows/main.yml/badge.svg
:alt: django-utils test status
:target: https://github.com/WoLpH/django-utils/actions
Coverage:
.. image:: https://coveralls.io/repos/WoLpH/django-utils/badge.svg?branch=master
:target: https://coveralls.io/r/WoLpH/django-utils?branch=master
Django Utils is a collection of small Django helper functions, utilities and
classes which make common patterns shorter and easier. It is by no means a
complete collection but it has served me quite a bit in the past and I will
keep extending it.
Examples are:
- Admin Select (Dropdown) filters
- Admin Select2 (Autocomplete dropdown) filters
- Admin JSON sub-field filters
- Enum based choicefields
- Models with automatic ``__str__``, ``__unicode__`` and ``__repr__`` functions
based on names and/or slugs using simple mixins.
- Models with automatic ``updated_at`` and ``created_at`` fields
- Models with automatic slugs based on the ``name`` property.
- Iterating through querysets in predefined chunks to prevent out of memory
errors
The library depends on the Python Utils library.
Documentation is available at: http://django-utils-2.readthedocs.io/en/latest/
Install
-------
To install:
1. Run ``pip install django-utils2`` or execute ``python setup.py install`` in the source directory
2. Add ``django_utils`` to your ``INSTALLED_APPS``
If you want to run the tests, run ``py.test`` (requirements in ``tests/requirements.txt``)
Admin Select / Dropdown / Autocomplete (JSON) Filters
-----------------------------------------------------
All of the standard admin list filters are available through ``django_utils
.admin.filters`` as:
- The original filter (e.g. ``SimpleListFilter``)
- A basic select/dropdown filter: ``SimpleListFilterDropdown``
- A select2 based autocompleting dropdown filter: ``SimpleListFilterSelect2``
On PostgreSQL you can additionally filter on JSON fields as well given paths:
.. code-block:: python
class SomeModelAdmin(admin.ModelAdmin):
list_filter = (
JSONFieldFilterSelect2.create('some_json_field__some__sub_path'),
)
That will filter a JSON field named ``some_json_field`` and look for values
like this:
.. code-block:: json
{"some": {"sub_path": "some value"}}
By default the results for the JSON filters are cached for 10 minutes but can
be changed through the ``create`` parameters.
Choices usage
-------------
To enable easy to use choices which are more convenient than the Django 3.0 choices system you can use this:
.. code-block:: python
from django_utils import choices
# For manually specifying the value (automatically detects ``str``, ``int`` and ``float``):
class Human(models.Model):
class Gender(choices.Choices):
MALE = 'm'
FEMALE = 'f'
OTHER = 'o'
gender = models.CharField(max_length=1, choices=Gender)
# To define the values as ``male`` implicitly:
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice()
FEMALE = choices.Choice()
OTHER = choices.Choice()
gender = models.CharField(max_length=1, choices=Gender)
# Or explicitly define them
class Human(models.Model):
class Gender(choices.Choices):
MALE = choices.Choice('m', 'male')
FEMALE = choices.Choice('f', 'female')
OTHER = choices.Choice('o', 'other')
gender = models.CharField(max_length=1, choices=Gender)
A PostgreSQL ENUM field will be coming soon to automatically facilitate the creation of the enum if needed.
Links
-----
* Documentation
- http://django-utils-2.readthedocs.org/en/latest/
* Source
- https://github.com/WoLpH/django-utils
* Bug reports
- https://github.com/WoLpH/django-utils/issues
* Package homepage
- https://pypi.python.org/pypi/django-utils2
* My blog
- http://w.wol.ph/
Raw data
{
"_id": null,
"home_page": "https://github.com/WoLpH/django-utils",
"name": "django-utils2",
"maintainer": "",
"docs_url": "https://pythonhosted.org/django-utils2/",
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Rick van Hattem",
"author_email": "Rick.van.Hattem@Fawo.nl",
"download_url": "https://files.pythonhosted.org/packages/46/52/3aeb057126fc83b1167f73e7e188af9e881dbccd5cae70e15d5741e5dc61/django-utils2-3.0.2.tar.gz",
"platform": null,
"description": "Introduction\n============\n\nBuild status:\n\n.. image:: https://github.com/WoLpH/django-utils/actions/workflows/main.yml/badge.svg\n :alt: django-utils test status\n :target: https://github.com/WoLpH/django-utils/actions\n\nCoverage:\n\n.. image:: https://coveralls.io/repos/WoLpH/django-utils/badge.svg?branch=master\n :target: https://coveralls.io/r/WoLpH/django-utils?branch=master\n\nDjango Utils is a collection of small Django helper functions, utilities and\nclasses which make common patterns shorter and easier. It is by no means a\ncomplete collection but it has served me quite a bit in the past and I will\nkeep extending it.\n\nExamples are:\n\n - Admin Select (Dropdown) filters\n - Admin Select2 (Autocomplete dropdown) filters\n - Admin JSON sub-field filters\n - Enum based choicefields\n - Models with automatic ``__str__``, ``__unicode__`` and ``__repr__`` functions\n based on names and/or slugs using simple mixins.\n - Models with automatic ``updated_at`` and ``created_at`` fields\n - Models with automatic slugs based on the ``name`` property.\n - Iterating through querysets in predefined chunks to prevent out of memory\n errors\n\nThe library depends on the Python Utils library.\n\nDocumentation is available at: http://django-utils-2.readthedocs.io/en/latest/\n\nInstall\n-------\n\nTo install:\n\n 1. Run ``pip install django-utils2`` or execute ``python setup.py install`` in the source directory\n 2. Add ``django_utils`` to your ``INSTALLED_APPS``\n \nIf you want to run the tests, run ``py.test`` (requirements in ``tests/requirements.txt``)\n\nAdmin Select / Dropdown / Autocomplete (JSON) Filters\n-----------------------------------------------------\n\nAll of the standard admin list filters are available through ``django_utils\n.admin.filters`` as:\n\n - The original filter (e.g. ``SimpleListFilter``)\n - A basic select/dropdown filter: ``SimpleListFilterDropdown``\n - A select2 based autocompleting dropdown filter: ``SimpleListFilterSelect2``\n\nOn PostgreSQL you can additionally filter on JSON fields as well given paths:\n\n.. code-block:: python\n\n class SomeModelAdmin(admin.ModelAdmin):\n list_filter = (\n JSONFieldFilterSelect2.create('some_json_field__some__sub_path'),\n )\n\nThat will filter a JSON field named ``some_json_field`` and look for values\nlike this:\n\n.. code-block:: json\n\n {\"some\": {\"sub_path\": \"some value\"}}\n\nBy default the results for the JSON filters are cached for 10 minutes but can\nbe changed through the ``create`` parameters.\n\nChoices usage\n-------------\n\nTo enable easy to use choices which are more convenient than the Django 3.0 choices system you can use this:\n\n.. code-block:: python\n\n from django_utils import choices\n\n\n # For manually specifying the value (automatically detects ``str``, ``int`` and ``float``):\n class Human(models.Model):\n class Gender(choices.Choices):\n MALE = 'm'\n FEMALE = 'f'\n OTHER = 'o'\n\n gender = models.CharField(max_length=1, choices=Gender)\n\n\n # To define the values as ``male`` implicitly:\n class Human(models.Model):\n class Gender(choices.Choices):\n MALE = choices.Choice()\n FEMALE = choices.Choice()\n OTHER = choices.Choice()\n\n gender = models.CharField(max_length=1, choices=Gender)\n\n\n # Or explicitly define them\n class Human(models.Model):\n class Gender(choices.Choices):\n MALE = choices.Choice('m', 'male')\n FEMALE = choices.Choice('f', 'female')\n OTHER = choices.Choice('o', 'other')\n\n gender = models.CharField(max_length=1, choices=Gender)\n\nA PostgreSQL ENUM field will be coming soon to automatically facilitate the creation of the enum if needed.\n\nLinks\n-----\n\n* Documentation\n - http://django-utils-2.readthedocs.org/en/latest/\n* Source\n - https://github.com/WoLpH/django-utils\n* Bug reports \n - https://github.com/WoLpH/django-utils/issues\n* Package homepage\n - https://pypi.python.org/pypi/django-utils2\n* My blog\n - http://w.wol.ph/\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Django Utils is a module with some convenient utilities not included with the standard Django install",
"version": "3.0.2",
"project_urls": {
"Homepage": "https://github.com/WoLpH/django-utils"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "535c6b279fb31dfeb8879ef420f26e4f494d40dce23189e6402f666e3a9d8100",
"md5": "f0c478e602182718313f87ba7300a009",
"sha256": "af8549618354381083fda6eadcae61d96a944fafb98717b0868c05ca2d6de276"
},
"downloads": -1,
"filename": "django_utils2-3.0.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "f0c478e602182718313f87ba7300a009",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 21781,
"upload_time": "2023-10-13T19:29:09",
"upload_time_iso_8601": "2023-10-13T19:29:09.078592Z",
"url": "https://files.pythonhosted.org/packages/53/5c/6b279fb31dfeb8879ef420f26e4f494d40dce23189e6402f666e3a9d8100/django_utils2-3.0.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "46523aeb057126fc83b1167f73e7e188af9e881dbccd5cae70e15d5741e5dc61",
"md5": "f4f5c736d7e5604179d509b840995e12",
"sha256": "e733bdb994854aa449eb829cbefab41c0106397b9db9cf24c8c64c381e185720"
},
"downloads": -1,
"filename": "django-utils2-3.0.2.tar.gz",
"has_sig": false,
"md5_digest": "f4f5c736d7e5604179d509b840995e12",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22825,
"upload_time": "2023-10-13T19:29:10",
"upload_time_iso_8601": "2023-10-13T19:29:10.420014Z",
"url": "https://files.pythonhosted.org/packages/46/52/3aeb057126fc83b1167f73e7e188af9e881dbccd5cae70e15d5741e5dc61/django-utils2-3.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-13 19:29:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "WoLpH",
"github_project": "django-utils",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "django-utils2"
}