Django Admin caching made easy
Project description
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_timeout
Release Notes
0.1.5 Update to supported versions. * Drop support for Django 1.8, 1.9 and 1.10 * Drop support for Python 3.2 and 3.4 * Remove compatibility code
0.1.5
bugfix: AttributeError if all translation has been deactivated - issue #10
0.1.4
bugfix: setup.py should not roll back latest Django version - issue #6
0.1.3
add support for Django 1.11 (and thus for Python 3.6 too)
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.5 3.6; 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)
Project details
Release history Release notifications | RSS feed
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_caching-0.1.8.tar.gz
.
File metadata
- Download URL: django_admin_caching-0.1.8.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd2474a5a6176e51d7d3e623fd7e08b324ae5c6c1db22b0fd2423d935ec200f8 |
|
MD5 | 9c7187932d9987e6e193cd47379f49aa |
|
BLAKE2b-256 | 274f180aa8ca8ac7c5a42e46afd1996d5a0efeaf7ffee93db88d920ead48d394 |
File details
Details for the file django_admin_caching-0.1.8-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin_caching-0.1.8-py2.py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.1 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.14.0 CPython/2.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 517fc2049cdb20136d64175ef3dd9cc4d945e9e5435114ea5117d76f87138a5a |
|
MD5 | 3583ef9a69d9283452a27a6ba03ca370 |
|
BLAKE2b-256 | 3bd9be69d4d91500c4411266ea92d55b51bfa7a87e64af98e7784b557d628174 |