{ "info": { "author": "Mohammad Javad Naderi", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP :: Session", "Topic :: Security" ], "description": ".. image:: https://user-images.githubusercontent.com/2115303/35397912-f00efbb4-0205-11e8-89b5-3d4f585a4588.png\n\n.. image:: https://img.shields.io/pypi/v/django-qsessions.svg\n :target: https://pypi.python.org/pypi/django-qsessions/\n\n.. image:: https://img.shields.io/travis/QueraTeam/django-qsessions.svg\n :target: https://travis-ci.org/QueraTeam/django-qsessions\n\n.. image:: https://img.shields.io/github/license/QueraTeam/django-qsessions.svg\n :target: https://github.com/QueraTeam/django-qsessions/blob/master/LICENSE.txt\n\n-------\n\ndjango-qsessions is a session backend for Django that extends Django's ``cached_db`` session backend\nand ``Session`` model to add following features:\n\n- Sessions have a foreign key to User\n\n- Sessions store IP and User Agent\n\n\nComparison\n==========\n\nHere is a brief comparison between Django's session backends (db, cache, cached_db), `django-user-sessions`_, and django-qsessions.\n\n+-------------------------+----+--------+-----------+----------------------+------------------+\n| | db | cache | cached_db | django-user-sessions | django-qsessions |\n+=========================+====+========+===========+======================+==================+\n| Better Performance | | \u2714\u2714 | \u2714 | | \u2714 |\n+-------------------------+----+--------+-----------+----------------------+------------------+\n| Persistent | \u2714 | | \u2714 | \u2714 | \u2714 |\n+-------------------------+----+--------+-----------+----------------------+------------------+\n| Foreign Key to User | | | | \u2714 | \u2714 |\n+-------------------------+----+--------+-----------+----------------------+------------------+\n| Store IP and User Agent | | | | \u2714 | \u2714 |\n+-------------------------+----+--------+-----------+----------------------+------------------+\n\n\n\n\nCompatibility\n=============\n\n+----------------+---------------------------+\n| Python version | Django versions |\n+================+===========================+\n| 3.7 | 2.0, 2.1, 2.2 |\n+----------------+---------------------------+\n| 3.6 | 1.10, 1.11, 2.0, 2.1, 2.2 |\n+----------------+---------------------------+\n| 3.5 | 1.10, 1.11, 2.0, 2.1, 2.2 |\n+----------------+---------------------------+\n| 3.4 | 1.10, 1.11, 2.0 |\n+----------------+---------------------------+\n| 2.7 | 1.10, 1.11 |\n+----------------+---------------------------+\n\nInstallation\n============\n\nPlease note that if your system is in production and there are lots of active sessions\nusing another session backend, you need to migrate them manually. We have no migration script.\n\n(1) First, make sure you've `configured your cache`_. If you have multiple caches defined in\n ``CACHES``, Django will use the default cache. To use another cache, set ``SESSION_CACHE_ALIAS``\n to the name of that cache.\n\n(2) Install the latest version from PyPI:\n\n .. code-block:: sh\n\n pip install django-qsessions\n\n(3) In settings:\n\n - In ``INSTALLED_APPS`` replace ``'django.contrib.sessions'`` with ``'qsessions'``.\n\n - In ``MIDDLEWARE`` or ``MIDDLEWARE_CLASSES`` replace\n ``'django.contrib.sessions.middleware.SessionMiddleware'`` with\n ``'qsessions.middleware.SessionMiddleware'``.\n\n - Set ``SESSION_ENGINE`` to ``'qsessions.backends.cached_db'``.\n\n(4) Run migrations to create ``qsessions.models.Session`` model.\n\n .. code-block:: sh\n\n python manage.py migrate qsessions\n\nFor enabling location detection using GeoIP2 (optional):\n\n(5) Install ``geoip2`` package:\n\n .. code-block:: sh\n\n pip install geoip2\n\n(6) Set ``GEOIP_PATH`` to a directory for storing GeoIP2 database.\n\n(7) Run the following command to download latest GeoIP2 database. You can add this command to a cron\n job to update GeoIP2 DB automatically.\n\n .. code-block:: sh\n\n python manage.py download_geoip_db\n\nUsage\n=====\n\ndjango-qsessions has a custom ``Session`` model with following fields:\n``user``, ``user_agent``, ``created_at``, ``updated_at``, ``ip``.\n\nGetting a user's sessions:\n\n.. code-block:: python\n\n user.session_set.filter(expire_date__gt=timezone.now())\n\nDeleting a session:\n\n.. code-block:: python\n\n # Deletes session from both DB and cache\n session.delete()\n\nLogout a user:\n\n.. code-block:: python\n\n user.session_set.all().delete()\n\nSession creation time (user login time):\n\n.. code-block:: python\n\n >>> session.created_at\n datetime.datetime(2018, 6, 12, 17, 9, 17, 443909, tzinfo=)\n\n\nIP and user agent:\n\n.. code-block:: python\n\n >>> session.ip\n '127.0.0.1'\n >>> session.user_agent\n 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'\n\nAnd if you have configured GeoIP2, you can call ``.location()``, ``.location_info()``:\n\n.. code-block:: python\n\n >>> session.location()\n 'Tehran, Iran'\n\n >>> session.location_info()\n {'city': 'Tehran', 'continent_code': 'AS', 'continent_name': 'Asia', 'country_code': 'IR', 'country_name': 'Iran', 'time_zone': 'Asia/Tehran', ...}\n\nAdmin page:\n\n.. image:: https://user-images.githubusercontent.com/2115303/41525284-b0b258b0-72f5-11e8-87f1-8770e0094f4c.png\n\nCaveats\n-------\n\n- ``session.updated_at`` is not the session's last activity. It's updated each time the session\n object in DB is saved. (e.g. when user logs in, or when ip, user agent, or session data changes)\n\nWhy not ``django-user-sessions``?\n=================================\n\n`django-user-sessions`_ has the same functionality,\nbut it's based on ``db`` backend. Using a cache will improve performance.\n\nWe got ideas and some codes from django-user-sessions.\nMany thanks to `Bouke Haarsma`_ for writing django-user-sessions.\n\nDevelopment\n===========\n\n* Install development dependencies in your virtualenv with ``pip install -e '.[dev]'``\n* Run tests with coverage using ``py.test --cov .``\n\n\nTODO\n====\n\n- Write better documentation.\n\n - Explain how it works (in summary)\n - Add more details to existing documentation.\n\n- Write more tests\n\n- Performance benchmark (and compare with Django's ``cached_db``)\n\nContributions are welcome!\n\nLicense\n=======\n\nMIT\n\n.. _`configured your cache`: https://docs.djangoproject.com/en/dev/topics/cache/\n.. _`django-user-sessions`: https://github.com/Bouke/django-user-sessions\n.. _`Bouke Haarsma`: https://github.com/Bouke", "description_content_type": "", "docs_url": null, "download_url": "https://pypi.python.org/pypi/django-qsessions", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/QueraTeam/django-qsessions", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-qsessions", "package_url": "https://pypi.org/project/django-qsessions/", "platform": "", "project_url": "https://pypi.org/project/django-qsessions/", "project_urls": { "Download": "https://pypi.python.org/pypi/django-qsessions", "Homepage": "https://github.com/QueraTeam/django-qsessions" }, "release_url": "https://pypi.org/project/django-qsessions/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Extends Django's cached_db session backend", "version": "0.2.1" }, "last_serial": 5239844, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "92f50bcec36bff25af87e73eaa0bf298", "sha256": "6af543396ebeea2888b0c7772dd93887e1e13a50be9dae022065c2c566f75bbb" }, "downloads": -1, "filename": "django-qsessions-0.1.2.tar.gz", "has_sig": false, "md5_digest": "92f50bcec36bff25af87e73eaa0bf298", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6701, "upload_time": "2018-01-20T15:12:15", "url": "https://files.pythonhosted.org/packages/8c/9a/935731c7f175a40b8b0e8d1d45ea2449e70cf665266b8756513506cf0f0a/django-qsessions-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "7913c81eebdd9f36254609017576a9a3", "sha256": "3253269f8ed3ff9122076cdae2a98c09403cb78007cfa9fe5b6425cfd9a4070a" }, "downloads": -1, "filename": "django-qsessions-0.1.3.tar.gz", "has_sig": false, "md5_digest": "7913c81eebdd9f36254609017576a9a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9862, "upload_time": "2018-02-03T12:18:02", "url": "https://files.pythonhosted.org/packages/a1/a0/aaebfa73cbf3670ed1c54e58c92aa7d35a27d6cd428d49192ef89b3bee25/django-qsessions-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "2631d1de498961371d2e2de3f038b36f", "sha256": "b01c7f37d3b44167b9671b0a5baf3cdd14b7177749509dde1c38e82063bd09b9" }, "downloads": -1, "filename": "django-qsessions-0.1.4.tar.gz", "has_sig": false, "md5_digest": "2631d1de498961371d2e2de3f038b36f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9979, "upload_time": "2018-02-05T07:05:45", "url": "https://files.pythonhosted.org/packages/e9/9e/c0fee7de7a23defbdcc07b2f6dba4990e19769789865dde82ab70df94b7a/django-qsessions-0.1.4.tar.gz" } ], "0.1.6": [ { "comment_text": "", "digests": { "md5": "d12a1e02cbb9091152bc30a18c6c428d", "sha256": "fd6e5bbaaf0250805d0b9c8295ae9d1064f42c3458b089e13984ad58997d917a" }, "downloads": -1, "filename": "django-qsessions-0.1.6.tar.gz", "has_sig": false, "md5_digest": "d12a1e02cbb9091152bc30a18c6c428d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10673, "upload_time": "2018-06-18T08:35:55", "url": "https://files.pythonhosted.org/packages/79/30/e86878af5ae1bac3a577b46f19eea1b6cc22c46940deab96467dbbf579f8/django-qsessions-0.1.6.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e95b9a519c9986a43c614fda03413e89", "sha256": "90d36b62353bda880a60516a2c53afab6ab19d7119001a5dc893d72f43e7bc1f" }, "downloads": -1, "filename": "django-qsessions-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e95b9a519c9986a43c614fda03413e89", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8707, "upload_time": "2018-12-24T20:42:30", "url": "https://files.pythonhosted.org/packages/e1/6a/47a710012cdf3305273677fcc3038c72c11994c9a4730c2cf050a0a1491a/django-qsessions-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9c33fbf5e207cc94d2687f1971ea858f", "sha256": "c9bb193cf90866703231e1e73f35f412f164cf062ed47417ec6b2608ef9311de" }, "downloads": -1, "filename": "django-qsessions-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9c33fbf5e207cc94d2687f1971ea858f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8680, "upload_time": "2019-05-07T20:09:35", "url": "https://files.pythonhosted.org/packages/f2/4f/f34f3f33ee6f602c32a6d0116c84b799cbd93a58da5538111773a96ee851/django-qsessions-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9c33fbf5e207cc94d2687f1971ea858f", "sha256": "c9bb193cf90866703231e1e73f35f412f164cf062ed47417ec6b2608ef9311de" }, "downloads": -1, "filename": "django-qsessions-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9c33fbf5e207cc94d2687f1971ea858f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8680, "upload_time": "2019-05-07T20:09:35", "url": "https://files.pythonhosted.org/packages/f2/4f/f34f3f33ee6f602c32a6d0116c84b799cbd93a58da5538111773a96ee851/django-qsessions-0.2.1.tar.gz" } ] }