Giter VIP home page Giter VIP logo

django-admin-caching's Introduction

django-admin-caching

WARNING:This project is currently frozen and will not longer be maintained. If there is someone interested in continuing to maintain this project please contact: [email protected] .
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!

  • 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)

  • 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
  • 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

As an open source project, we welcome contributions.

The code lives on github.

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.

  • 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
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

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)

django-admin-caching's People

Contributors

belugame avatar eorhim avatar jm9e avatar kairichard avatar konstantinpae avatar markschmidts avatar yunera avatar zsoldosp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-admin-caching's Issues

Drop support for Python 3.3

Hello,

You should consider dropping python3.3 support. It fails in travis since the used version of wheelno longer supports it. Thats why the build of the pull request of @n0sk and me fails.

when django-admin-caching is enabled, update_or_create() function always return None

when I include this package in the INSTALLED_APPS in the setting.py, running update_or_create() method from object queryset API always return "'NoneType' object has no attribute 'find'". i pretty sure the object is exist because if i use get_or_create() then it works.

Not sure what happen but i really like this package, it really make admin running faster.

Thanks

Nick

Support for Django>=1.11

It seems the setup.py pins Django 1.11, rolling my Django back 2 minors, is there any reason for this ? Any chance of a change to allow the current 1.11.2 ?

Support for Django 2.0

Django 2.0 has been released but this package currently requires'Django>=1.8,<1.12' as dependency.

CacheKeyWarning: Cache key contains characters that will cause errors if used with memcached:

e.g.: with py36-django111

tests/testapp/tests/test_autokeyed_cache.py::test_after_runtime_key_change_its_not_in_cache
  /var/www/gitlibs/django-admin-caching/.tox/py36-django111/lib/python3.6/site-packages/django/core/cache/backends/base.py:243: CacheKeyWarning: Cache key contains characters that will cause errors if used with memcached: ':1:testapp.admin.MyGroupAdmin-auth.Group-first key'
    'used with memcached: %r' % key, CacheKeyWarning
  /var/www/gitlibs/django-admin-caching/.tox/py36-django111/lib/python3.6/site-packages/django/core/cache/backends/base.py:243: CacheKeyWarning: Cache key contains characters that will cause errors if used with memcached: ':1:testapp.admin.MyGroupAdmin-auth.Group-second key'
    'used with memcached: %r' % key, CacheKeyWarning

tests/testapp/tests/test_autokeyed_cache.py::test_can_remove_itself_from_the_cache
  /var/www/gitlibs/django-admin-caching/.tox/py36-django111/lib/python3.6/site-packages/django/core/cache/backends/base.py:243: CacheKeyWarning: Cache key contains characters that will cause errors if used with memcached: ':1:other key'
    'used with memcached: %r' % key, CacheKeyWarning

-- Docs: http://doc.pytest.org/en/latest/warnings.html

Django 2.2

Please provide support for django 2.2.2 as i had to rollback to 2.1.9 to install django-admin-caching.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.