{"id":18147528,"url":"https://github.com/audiolion/django-groups-cache","last_synced_at":"2025-04-23T21:51:14.629Z","repository":{"id":57420311,"uuid":"78668854","full_name":"audiolion/django-groups-cache","owner":"audiolion","description":"Cache django user groups for fast checking!","archived":false,"fork":false,"pushed_at":"2022-07-15T18:41:00.000Z","size":47,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-15T13:44:47.173Z","etag":null,"topics":["cache","django","groups"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/audiolion.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-11T18:50:45.000Z","updated_at":"2023-08-23T12:58:23.000Z","dependencies_parsed_at":"2022-09-15T02:42:25.201Z","dependency_job_id":null,"html_url":"https://github.com/audiolion/django-groups-cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiolion%2Fdjango-groups-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiolion%2Fdjango-groups-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiolion%2Fdjango-groups-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/audiolion%2Fdjango-groups-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/audiolion","download_url":"https://codeload.github.com/audiolion/django-groups-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522293,"owners_count":21444510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","django","groups"],"created_at":"2024-11-01T22:06:48.331Z","updated_at":"2025-04-23T21:51:14.613Z","avatar_url":"https://github.com/audiolion.png","language":"Python","readme":"=============================\ndjango-groups-cache\n=============================\n\n.. image:: https://badge.fury.io/py/django-groups-cache.svg\n    :target: https://badge.fury.io/py/django-groups-cache\n\n.. image:: https://travis-ci.org/audiolion/django-groups-cache.svg?branch=master\n    :target: https://travis-ci.org/audiolion/django-groups-cache\n\n.. image:: https://codecov.io/gh/audiolion/django-groups-cache/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/audiolion/django-groups-cache\n\nCaches the groups a user is in so requests don't have to make calls to the database to check group status.\n\nSupport\n-------\n\nCurrently supporting Django 1.8, 1.11, and 2.0 with Python 2.7/Python 3 where support for versions aligns with\nDjango's support. See the `tox.ini` file for specific Python and Django version pairings.\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-groups-cache.readthedocs.io.\n\nQuickstart\n----------\n\nInstall django-groups-cache::\n\n    pip install django-groups-cache\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'groups_cache.apps.GroupsCacheConfig',\n        ...\n    )\n\nAdd the middleware to your `MIDDLEWARE_CLASSES`:\n\n.. code-block:: python\n\n    MIDDLEWARE_CLASSES = (\n        'django.contrib.sessions.middleware.SessionMiddleware',\n        'django.contrib.auth.middleware.AuthenticationMiddleware',\n        ...\n        'groups_cache.middleware.GroupsCacheMiddleware',\n    )\n\nChecking in a Django Template if the user is in a group name:\n\n.. code-block:: python\n\n    {% if \"admins\" in request.groups_cache %}\n      \u003ca href=\"/admin\"\u003eAdmin Panel\u003c/a\u003e\n    {% endif %}\n\n    # or use templatetag, note that templatetag is slower\n\n    {% load has_group %}\n\n    {% if request.user|has_group:\"admins\" %}\n      \u003ca href=\"/admin\"\u003eAdmin Panel\u003c/a\u003e\n    {% endif %}\n\nTurn on caching:\n\n.. code-block:: python\n\n    CACHES = {\n        'default': {\n            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',\n            'LOCATION': '127.0.0.1:11211',\n        }\n    }\n\nSee https://docs.djangoproject.com/en/1.10/topics/cache/#memcached for more details on setting\nup memcached.\n\nNote**\n\nUsing `django.core.cache.backends.locmem.LocMemCache` is not safe for production unless you are\nonly running a single process (and odds are you aren't).\n\nSee https://docs.djangoproject.com/en/1.10/topics/cache/#local-memory-caching for more details.\n\nFeatures\n--------\n\n* Adds `groups_cache` property to `request` object\n* Provides templatetag `has_group`\n* Invalidates cache on `User` or `Group` model changes and on m2m `groups` ManyToManyField changes\n* Fully tested with high coverage\n\n\nRunning Tests\n-------------\n\n::\n\n    source \u003cYOURVIRTUALENV\u003e/bin/activate\n    (myenv) $ pip install tox\n    (myenv) $ tox\n\nCredits\n-------\n\nTools used in rendering this package:\n\n*  Cookiecutter_\n*  `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiolion%2Fdjango-groups-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faudiolion%2Fdjango-groups-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faudiolion%2Fdjango-groups-cache/lists"}