Using django admin date hierarchy queries free!
Project description
=============================
Django Admin lightweight date hierarchy
=============================
.. image:: https://badge.fury.io/py/django-admin-lightweight-date-hierarchy.svg
:target: https://badge.fury.io/py/django-admin-lightweight-date-hierarchy
.. image:: https://travis-ci.org/hakib/django-admin-lightweight-date-hierarchy.svg?branch=master
:target: https://travis-ci.org/hakib/django-admin-lightweight-date-hierarchy
.. image:: https://codecov.io/gh/hakib/django-admin-lightweight-date-hierarchy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/hakib/django-admin-lightweight-date-hierarchy
Django Admin date_hierarchy with zero queries
----------------------------------------------
The built-in `date_hierarchy`_ tag performs a query to find the dates for which there is data.
On large tables this query can be very expensive.
To prevent additional queries, set ``date_hierarchy_drilldown = False`` on the ``ModelAdmin``.
When drill-down is disabled the tag will generate a default range of dates based solely
on the selected hierarchy level - without performing a query.
Default options for hierarchy levels:
- None - +-3 years from current year.
- Year - all months of the selected year.
- Month - all days of the selected month.
When ``date_hierarchy_drilldown = True`` or when not set the default behaviour is preserved.
.. _`date_hierarchy`: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.date_hierarchy
Support
----------
Python 2.7, 3.4, 3.5, 3.6
Django 1.9, 1.10, 1.11
Quickstart
----------
Install django-admin-lightweight-date-hierarchy::
pip install django-admin-lightweight-date-hierarchy
Add it to your `INSTALLED_APPS`:
.. code-block:: python
INSTALLED_APPS = (
...
'django_admin_lightweight_date_hierarchy',
...
)
Add the following to any ``ModelAdmin`` with ``date_hierarchy`` to prevent the default drill-down behaviour:
.. code-block:: python
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
date_hierarchy = 'created'
date_hierarchy_drilldown = False
Running Tests
-------------
::
source <YOURVIRTUALENV>/bin/activate
(venv) $ pip install tox
(venv) $ tox
Credits
-------
Tools used in rendering this package:
* Cookiecutter_
* `cookiecutter-djangopackage`_
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
History
-------
0.1.0 (2017-09-21)
++++++++++++++++++
* First release on PyPI.
Django Admin lightweight date hierarchy
=============================
.. image:: https://badge.fury.io/py/django-admin-lightweight-date-hierarchy.svg
:target: https://badge.fury.io/py/django-admin-lightweight-date-hierarchy
.. image:: https://travis-ci.org/hakib/django-admin-lightweight-date-hierarchy.svg?branch=master
:target: https://travis-ci.org/hakib/django-admin-lightweight-date-hierarchy
.. image:: https://codecov.io/gh/hakib/django-admin-lightweight-date-hierarchy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/hakib/django-admin-lightweight-date-hierarchy
Django Admin date_hierarchy with zero queries
----------------------------------------------
The built-in `date_hierarchy`_ tag performs a query to find the dates for which there is data.
On large tables this query can be very expensive.
To prevent additional queries, set ``date_hierarchy_drilldown = False`` on the ``ModelAdmin``.
When drill-down is disabled the tag will generate a default range of dates based solely
on the selected hierarchy level - without performing a query.
Default options for hierarchy levels:
- None - +-3 years from current year.
- Year - all months of the selected year.
- Month - all days of the selected month.
When ``date_hierarchy_drilldown = True`` or when not set the default behaviour is preserved.
.. _`date_hierarchy`: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.date_hierarchy
Support
----------
Python 2.7, 3.4, 3.5, 3.6
Django 1.9, 1.10, 1.11
Quickstart
----------
Install django-admin-lightweight-date-hierarchy::
pip install django-admin-lightweight-date-hierarchy
Add it to your `INSTALLED_APPS`:
.. code-block:: python
INSTALLED_APPS = (
...
'django_admin_lightweight_date_hierarchy',
...
)
Add the following to any ``ModelAdmin`` with ``date_hierarchy`` to prevent the default drill-down behaviour:
.. code-block:: python
@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
date_hierarchy = 'created'
date_hierarchy_drilldown = False
Running Tests
-------------
::
source <YOURVIRTUALENV>/bin/activate
(venv) $ pip install tox
(venv) $ tox
Credits
-------
Tools used in rendering this package:
* Cookiecutter_
* `cookiecutter-djangopackage`_
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
History
-------
0.1.0 (2017-09-21)
++++++++++++++++++
* First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-admin-lightweight-date-hierarchy-0.1.0.tar.gz
.
File metadata
- Download URL: django-admin-lightweight-date-hierarchy-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1ef25ad4efd469adec6b303f35d753315c21b046dfcfa0ba15afdde177af797 |
|
MD5 | 62c359ca2bcd4739c3a255c1dbc99d5a |
|
BLAKE2b-256 | 4a646e77b525fa739c97232d1a499bf8130ee7ed0c85d727e9c958b23418ad1e |
File details
Details for the file django_admin_lightweight_date_hierarchy-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin_lightweight_date_hierarchy-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3334bb706cc5f4beb2290e1eac38465ab9f1abf0d45f1841d3cd3a132633229c |
|
MD5 | c75638a5913d4b66cd45891e23f1e26b |
|
BLAKE2b-256 | 5b4619af60ecdc0b1e07e1d08d753da28c76cc83077598c61d3548c208f32f91 |