{"id":14972835,"url":"https://github.com/missterhao/django-dysession","last_synced_at":"2025-08-24T06:33:32.386Z","repository":{"id":65585535,"uuid":"585412176","full_name":"MissterHao/django-dysession","owner":"MissterHao","description":"django-dysession is a django extension by using AWS DynamoDB as a session backend","archived":false,"fork":false,"pushed_at":"2023-02-13T05:48:45.000Z","size":1063,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T00:14:39.963Z","etag":null,"topics":["aws","django","django-framework","django-session","dynamodb","python","session","session-management"],"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/MissterHao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-05T05:17:42.000Z","updated_at":"2023-02-18T13:02:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"05936b94-2f08-4f84-ad8c-426d9f0fff03","html_url":"https://github.com/MissterHao/django-dysession","commit_stats":{"total_commits":52,"total_committers":1,"mean_commits":52.0,"dds":0.0,"last_synced_commit":"0609efbb648e5365d706ac479e118c9a82ac2ab8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MissterHao%2Fdjango-dysession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MissterHao%2Fdjango-dysession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MissterHao%2Fdjango-dysession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MissterHao%2Fdjango-dysession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MissterHao","download_url":"https://codeload.github.com/MissterHao/django-dysession/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238397210,"owners_count":19465134,"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":["aws","django","django-framework","django-session","dynamodb","python","session","session-management"],"created_at":"2024-09-24T13:47:36.805Z","updated_at":"2025-02-12T01:33:08.301Z","avatar_url":"https://github.com/MissterHao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003edjango-dysession\u003c/h1\u003e\n\u003cp\u003edjango-dysession is a django extension by using AWS DynamoDB as a session backend\u003c/p\u003e\n\u003cimg src=\"asset/banner.png\" alt=\"django-dysession\" width=\"640\" height=\"320\" /\u003e\n\u003c!-- \u003cimg src=\"https://socialify.git.ci/MissterHao/django-dysession/image?description=1\u0026font=Source%20Code%20Pro\u0026language=1\u0026name=1\u0026owner=1\u0026pattern=Plus\u0026stargazers=1\u0026theme=Light\" alt=\"django-dysession\" width=\"640\" height=\"320\" /\u003e --\u003e\n\n\u003cp align=\"center\" \u003e\n\u003c!-- First line --\u003e\n\u003ca href=\"https://codecov.io/gh/MissterHao/django-dysession\" style=\"margin-right: 8px;\"\u003e\n\u003cimg src=\"https://img.shields.io/codecov/c/gh/MissterHao/django-dysession?style=for-the-badge\u0026token=M0U87NR9KI\u0026logo=Codecov\" alt=\"codecov\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/MissterHao/django-dysession\"\u003e\n\u003cimg src=\"https://img.shields.io/pypi/pyversions/django-dysession?style=for-the-badge\u0026logo=Python\" alt=\"Supported Python version badge\" \u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\u003c!-- Second line --\u003e\n\u003ca href=\"https://github.com/MissterHao/django-dysession\" style=\"margin-right: 8px;\"\u003e\n\u003cimg src=\"https://img.shields.io/github/issues/MissterHao/django-dysession?style=for-the-badge\" alt=\"Github Issue badge\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/MissterHao/django-dysession\" style=\"margin-right: 8px;\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/MissterHao/django-dysession?style=for-the-badge\" alt=\"Lience badge\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/MissterHao/django-dysession\" style=\"margin-right: 8px;\"\u003e\n\u003cimg src=\"https://img.shields.io/pypi/dm/django-dysession?logo=python\u0026style=for-the-badge\" alt=\"Downloads badge\" /\u003e\n\u003c/a\u003e\n\u003cbr\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n\n## What is a django-dysession?\n\nDjango-dysession is a simple and easy-to-use app which allow Django developers to take DyanmoDB as Session Backend Database.\n\nDynamoDB is Fast, flexible NoSQL database service for single-digit millisecond performance at any scale.\n\nUsing DynamoDB for session storage alleviates issues that occur with session handling in a distributed web application by moving sessions off of the local file system and into a shared location. [[1]]\n\n+ Easy to use! All you need is add **2 lines** of Code!\n+ Support **TTL(Time to Live) attribute**\n  Django's default session won't delete expired session data.\n  By using DynamoDB, we can take advantage of DynamoDB's ttl attrubute to auto delete expired session data.\n+ No more effort to maintain and autoscale your session database ( Taking advantage of AWS serverless service! )\n+ Provide beautiful, clearful and colorful error log\n\n\n## Requirements\n**django-dysession** use [boto3](https://aws.amazon.com/tw/sdk-for-python/) to interact with AWS DynamoDB.\nBoto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like **DynamoDB**.\n\n+ Django \u003e= 3.2\n+ boto3 \u003e= 1.26.59\n\n## Installation\n\nInstall from PyPI ( or manually download from [PyPI](https://pypi.org/project/django-dysession/#files) ):\n```bash\npip install -U django-dysession\n```\n\n## Getting Started\nFirst of all, add `dysession` into `INSTALLED_APPS` in settings.py.\nChange `SESSION_ENGINE` to `dysession.backends.db` in order use our SessionStore.\n```python\nINSTALLED_APPS = [\n    ...\n    \"dysession\", # add dysession to installed apps\n    # 'django.contrib.sessions', # remove this default session\n    ...\n]\n\nSESSION_ENGINE = \"dysession.backends.db\"\n```\n\nSecond, we need to create a DynamoDB to store session data which's name is `sessions` as default.\nRun the commands bellow in cmd.\n```bash\npython manage.py dysession_init\n```\n\nThen, we can enjoy it now!\n```python\nfrom django.http import HttpResponse\n\ndef mainpage(request):\n    request.session[\"is_admin\"] = True\n    request.session[\"bottle_of_milks\"] = 20\n    request.session[\"planet_have_been_to\"] = [\"Earth\", \"Jupiter\", \"Saturn\"]\n\n    return HttpResponse(\"Ayyy\")\n```\n\nEnjoy!\n\n![](asset/dynamodb-real-demo-image.png)\n\n\n## Django Commands\n\ndjango-dysession offer two commands for developers:\n+ dysession_destory: Destory DynamoDB Table ( Will delete whole data of the table )\n+ dysession_init: Create DyanmoDB Table\n\n```bash\npython manage.py --help\n\nType 'manage.py help \u003csubcommand\u003e' for help on a specific subcommand.\n\nAvailable subcommands:\n\n[dysession]\n    dysession_destory\n    dysession_init\n```\n\n## Settings\n\nThis section outlines all the settings and configurations that you can put in Django's settings.py to adjust `dysession`'s behavior.\n\nYou can overwrite any value in `DYSESSION` or just ignore it to use the default value!\n```python\nDYSESSION = {\n    \"DYNAMODB_TABLENAME\": \"sessions\",\n    \"PARTITION_KEY_NAME\": \"PK\",\n    \"SORT_KEY_NAME\": \"SK\",\n    \"TTL_ATTRIBUTE_NAME\": \"ttl\",\n    \"CACHE_PERIOD\": 3600,\n    \"DYNAMODB_REGION\": \"ap-northeast-1\",\n    \"LOGGING\": {\n        \"TYPE\": \"CONSOLE\",\n    },\n}\n```\n\n| Argument             | Default        | Description                                                                                                                                                                                                                                               |\n|----------------------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| DYNAMODB_TABLENAME   | sessions       | DynamoDB table name                                                                                                                                                                                                                                       |\n| PARTITION_KEY_NAME   | PK             | Partition key name                                                                                                                                                                                                                                        |\n| TTL_ATTRIBUTE_NAME   | ttl            | Time to live attribute name                                                                                                                                                                                                                               |\n| CACHE_PERIOD         | 3600           | Define how long should be the cache live in DynamoDB's table                                                                                                                                                                                              |\n| DYNAMODB_REGION      | ap-northeast-1 | The region of the DynamoDB table                                                                                                                                                                                                                          |\n| LOGGING              | Dict           | Configuration of Logging                                                                                                                                                                                                                                  |\n| LOGGING[\"TYPE\"]      | CONSOLE        | Only accept two kinds of parameters: `CONSOLE`, `FILE`. If this set to `CONSOLE`, django-dysession will use `StreamHandler` to stream to the console. If this set to `FILE`, django-dysession will use `FileHandler` to stream to `LOGGING[\"FILE_PATH\"]`. |\n| LOGGING[\"FILE_PATH\"] | session.log    | Optional. Only use this configuration when LOGGING[\"TYPE\"] is set to `FILE`. The file path to save logs of session managements.                                                                                                                           |\n\n\n## Logging\n\nDjango-Dysession support three kinds of logging.\n\n1. Colorful TTY-based Console Log\n\n   Support colorful and beautiful log when django-dysession interacting with AWS Dysession.\n   ![](/asset/dysession-beautiful-error-log-example.png)\n2. Default logging stream\n\n   Django-Dysession use python core library `logging.StreamHandler`\n3. Default File Stream\n\n   Django-Dysession use python core library `logging.FileHandler`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmissterhao%2Fdjango-dysession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmissterhao%2Fdjango-dysession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmissterhao%2Fdjango-dysession/lists"}