Skip to main content

django-admin-caching

https://travis-ci.org/PaesslerAG/django-admin-caching.svg?branch=master

The Django admin changelist rows are not contained within a block that could be extended through standard template caching with tags. Also, the generation of the cache key for more complex objects might be too complicated to do in the templates. Plus there might be out-of-process changes (e.g.: one of manual data fixes) that don’t change the cache key, but should invalidate the cached row.

Hence the existence of this application - declaratively cache your admin rows!

Setup

  • install it via pip install django-admin-caching

  • add it to your settings and it auto-registers itself

    settings.INSTALLED_APPS = [
       ...
       'django_admin_caching',
       ...
    ]
  • configure the admins you want cached (see below for detail)

Configuring the admin

  • to enable cahcing, the admin_caching_enabled attribute of the model’s admin class must be set to True. Note this means you might need to unregister the default admin and register your custom one for third party models (e.g.: django.contrib.auth.models.Group)

  • the cache key by default is <admin class module name>.<admin class name>- <model class app label>.<model class name>-<model object pk>. This could be customized by adding a custom key method to the admin class that returns the string key for the model object part of the key - def admin_caching_key(self, obj)

    • if settings.USE_I18N (and settings.USE_L10N) are enabled, for each enabled setting, a prefix will be added to the above, e.g.: <language name>.<locale name>.<the key from above>

  • on the admin level, the cache’s name can be specified through the admin_caching_cache_name attribute. If omitted, it defaults to default

  • on the admin level, the cache’s timeout can be specified through the admin_caching_timeout_seconds attribute. If omitted, it defaults to the cache’s default_tiemout

Release Notes

  • 0.1.2

    • if i18n/l10n is enabled, account for it in the cache prefix

  • 0.1.1

    • allow specifying the cache timeout on the admin class

  • 0.1.0 - initial release

    • supports Django 1.8, 1.9, 1.10 on python 2.7, 3.3, 3.4, and 3.5

    • supports the following configuration attributes on the admin class

      • admin_caching_enabled

      • admin_caching_cache_name

      • admin_caching_key for custom object cache key

Contributing

As an open source project, we welcome contributions.

The code lives on github.

Reporting issues/improvements

Please open an issue on github or provide a pull request whether for code or for the documentation.

For non-trivial changes, we kindly ask you to open an issue, as it might be rejected. However, if the diff of a pull request better illustrates the point, feel free to make it a pull request anyway.

Pull Requests

  • for code changes

    • it must have tests covering the change. You might be asked to cover missing scenarios

    • the latest flake8 will be run and shouldn’t produce any warning

    • if the change is significant enough, documentation has to be provided

Setting up all Python versions

sudo apt-get -y install software-properties-common
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
for version in 3.3 3.5; do
  py=python$version
  sudo apt-get -y install ${py} ${py}-dev
done

Code of Conduct

As it is a Django extension, it follows Django’s own Code of Conduct. As there is no mailing list yet, please just email one of the main authors (see setup.py file or github contributors)

Release files for django-admin-caching 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-caching 0.1.2
File Size Uploaded
django_admin_caching-0.1.2.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-caching 0.1.2
File Interpreter ABI Platform
django_admin_caching-0.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 14.8 kB

Release files / django_admin_caching-0.1.2.tar.gz

Download URL django_admin_caching-0.1.2.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
de48443e616f94dd4890016a8786d1e26e95302d9a6f9345d82f2c423cabacb4
BLAKE2b-256 checksum
How to use checksums
36bd5cdedf8b813873a43d86824e0c278873ff4249ece84bea8cce13e9a0d3d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_admin_caching-0.1.2-py2.py3-none-any.whl

Download URL django_admin_caching-0.1.2-py2.py3-none-any.whl
Size 8.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6d84a2850b40f9950e795f854cc59c0e82b53942d33aee39fbcbb8e82dff0e81
BLAKE2b-256 checksum
How to use checksums
1bc6a7dae4be96e626be01e8807e7d997ad179fe686933ee63e504cfb0fefb83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page