{ "info": { "author": "Selwin Ong", "author_email": "selwin.ong@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Django User Agents\n==================\n\nA django package that allows easy identification of visitor's browser, OS and device information,\nincluding whether the visitor uses a mobile phone, tablet or a touch capable device. Under the hood,\nit uses `user-agents `_.\n\n\nInstallation\n============\n\n1. Install ``django-user-agents``, you'll have to make sure that `user-agents`_ is installed first::\n\n pip install pyyaml ua-parser user-agents\n pip install django-user-agents\n\n2. Configure ``settings.py``:\n\n .. code-block:: python\n\n INSTALLED_APPS = (\n # Other apps...\n 'django_user_agents',\n )\n\n # Cache backend is optional, but recommended to speed up user agent parsing\n CACHES = {\n 'default': {\n 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',\n 'LOCATION': '127.0.0.1:11211',\n }\n }\n\n # Name of cache backend to cache user agents. If it not specified default\n # cache alias will be used. Set to `None` to disable caching.\n USER_AGENTS_CACHE = 'default'\n\nUsage\n=====\n\nMiddleware\n----------\n\nAdd ``UserAgentMiddleware`` in ``settings.py``:\n\n.. code-block:: python\n\n MIDDLEWARE_CLASSES = (\n # other middlewares...\n 'django_user_agents.middleware.UserAgentMiddleware',\n )\n\nA ``user_agent`` attribute will now be added to ``request``, which you can use\nin ``views.py``:\n\n.. code-block:: python\n\n def my_view(request):\n\n # Let's assume that the visitor uses an iPhone...\n request.user_agent.is_mobile # returns True\n request.user_agent.is_tablet # returns False\n request.user_agent.is_touch_capable # returns True\n request.user_agent.is_pc # returns False\n request.user_agent.is_bot # returns False\n\n # Accessing user agent's browser attributes\n request.user_agent.browser # returns Browser(family=u'Mobile Safari', version=(5, 1), version_string='5.1')\n request.user_agent.browser.family # returns 'Mobile Safari'\n request.user_agent.browser.version # returns (5, 1)\n request.user_agent.browser.version_string # returns '5.1'\n\n # Operating System properties\n request.user_agent.os # returns OperatingSystem(family=u'iOS', version=(5, 1), version_string='5.1')\n request.user_agent.os.family # returns 'iOS'\n request.user_agent.os.version # returns (5, 1)\n request.user_agent.os.version_string # returns '5.1'\n\n # Device properties\n request.user_agent.device # returns Device(family='iPhone')\n request.user_agent.device.family # returns 'iPhone'\n\nIf you have ``django.core.context_processors.request`` enabled, ``user_agent``\nwill also be available in template through ``request``:\n\n.. code-block:: html+django\n\n {% if request.user_agent.is_mobile %}\n Do stuff here...\n {% endif %}\n\n\nView Usage\n----------\n\n``django-user_agents`` comes with ``get_user_agent`` which takes a single\n``request`` argument and returns a ``UserAgent`` instance. Example usage:\n\n.. code-block:: python\n\n from django_user_agents.utils import get_user_agent\n\n def my_view(request):\n user_agent = get_user_agent(request)\n if user_agent.is_mobile:\n # Do stuff here...\n elif user_agent.is_tablet:\n # Do other stuff...\n\n\nTemplate Usage\n--------------\n\n``django-user_agents`` comes with a few template filters:\n\n* ``is_mobile``\n* ``is_tablet``\n* ``is_touch_capable``\n* ``is_pc``\n* ``is_bot``\n\nYou can use all of these like any other django template filters:\n\n.. code-block:: html+django\n\n {% load user_agents %}\n\n {% if request|is_mobile %}\n Mobile device stuff...\n {% endif %}\n\n {% if request|is_tablet %}\n Tablet stuff...\n {% endif %}\n\n {% if request|is_pc %}\n PC stuff...\n {% endif %}\n\n {% if request|is_touch_capable %}\n Touch capable device stuff...\n {% endif %}\n\n {% if request|is_bot %}\n Bot stuff...\n {% endif %}\n\n\nYou can find out more about user agent attributes at `here `_.\n\n\nRunning Tests\n=============\n\n.. code-block:: console\n\n `which django-admin.py` test django_user_agents --settings=django_user_agents.tests.settings --pythonpath=.\n\n\nChangelog\n=========\n\n0.4.0\n-----\n* Add support for Django 2.0 to 2.2. Thanks @adamchainz and @joehybird!\n\n0.3.1\n-----\n* Fixed a bug when request have no META attribute\n\n0.3.0\n-----\n* Python 3, thanks to @hwkns!\n\n0.2.2\n-----\n* Fixed a bug that causes cache set/read to fail when user agent is longer than 250 characters\n\n0.2.1\n-----\n* Fixed packaging\n\n0.2.0\n-----\n* Added template filters\n* Added ``get_user_agent`` function in utils.py\n\n0.1.1\n-----\n* Fixed a ``KeyError`` exception in the case of empty ``HTTP_USER_AGENT``\n\n0.1\n---\n* Initial release\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/selwin/django-user_agents", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-user-agents", "package_url": "https://pypi.org/project/django-user-agents/", "platform": "", "project_url": "https://pypi.org/project/django-user-agents/", "project_urls": { "Homepage": "https://github.com/selwin/django-user_agents" }, "release_url": "https://pypi.org/project/django-user-agents/0.4.0/", "requires_dist": [ "django", "user-agents" ], "requires_python": "", "summary": "A django package that allows easy identification of visitors' browser, operating system and device information (mobile phone, tablet or has touch capabilities).", "version": "0.4.0" }, "last_serial": 5434669, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8aa8ecb4596d94038f5cb8ed9aa00e59", "sha256": "31a60eabdd2f7b0a84d1d4d99862859e86a2d1f36299a7adf8d55b0a9f0eead3" }, "downloads": -1, "filename": "django-user_agents-0.1.tar.gz", "has_sig": false, "md5_digest": "8aa8ecb4596d94038f5cb8ed9aa00e59", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3464, "upload_time": "2013-01-06T03:07:47", "url": "https://files.pythonhosted.org/packages/07/9c/4650d40c147dad22491a017d3d74bc6e71dfd2afaea98b811adf8a2a3268/django-user_agents-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "817bae31f855bba6dc296e7ed5fcd8dd", "sha256": "b02bdb990cabe75ac1531fc9540c076a5958c255c575adeacec883582d6deaa2" }, "downloads": -1, "filename": "django-user_agents-0.1.1.tar.gz", "has_sig": false, "md5_digest": "817bae31f855bba6dc296e7ed5fcd8dd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3566, "upload_time": "2013-01-07T14:48:47", "url": "https://files.pythonhosted.org/packages/af/d0/a8e46722c4cab84ae872bc5e9787654719fbb18f1ae877784eddde36de81/django-user_agents-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e7da7b8ec471b0d5ac45b214c12901a1", "sha256": "9c13f015127764cbe319313fd9785cb201b667f2b3b7750c84a33894f5ee3cf1" }, "downloads": -1, "filename": "django-user_agents-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e7da7b8ec471b0d5ac45b214c12901a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4398, "upload_time": "2013-01-10T12:44:38", "url": "https://files.pythonhosted.org/packages/50/13/0166ef9fc49591035cf46b3c7906a9aac7da4f8bade823695b0f4bccc0e7/django-user_agents-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "a1b550a8f41a41ced9dc326439479180", "sha256": "b02d7e9b4fe612875110c57584254d33f6e795cd51e312c3993b9e8f33b397a9" }, "downloads": -1, "filename": "django-user_agents-0.2.1.tar.gz", "has_sig": false, "md5_digest": "a1b550a8f41a41ced9dc326439479180", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5716, "upload_time": "2013-02-16T14:09:37", "url": "https://files.pythonhosted.org/packages/b1/0a/b75f5ddd391186d71c5a2b7abdd022d663a5c46a8c871bdcd049c00aa939/django-user_agents-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "9aee092dfe0374f3d28920a51b6d7651", "sha256": "81f65edb18c3f8063205608888cd67eed3b7232bc54e91dbe633acd0ed6dfb06" }, "downloads": -1, "filename": "django-user_agents-0.2.2.tar.gz", "has_sig": false, "md5_digest": "9aee092dfe0374f3d28920a51b6d7651", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6012, "upload_time": "2013-03-28T02:29:32", "url": "https://files.pythonhosted.org/packages/c5/b5/7271f8a1d903d0bd2130e6cd8181ad3977d34f65e88b125b3674616ec18e/django-user_agents-0.2.2.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "229f381402db466e7c93d90723198d22", "sha256": "1b9c37f3111dd5b84a01cde9b4842eb338fa1e9340868faed1278e49c504d7cf" }, "downloads": -1, "filename": "django_user_agents-0.3.0-py2-none-any.whl", "has_sig": false, "md5_digest": "229f381402db466e7c93d90723198d22", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10162, "upload_time": "2014-08-24T08:32:22", "url": "https://files.pythonhosted.org/packages/84/1f/c4793f67501957f655d71bb62c91bdac5593abae04b593d1df8f9f3f6857/django_user_agents-0.3.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d56d5f15da833826df9cb0a4d760e394", "sha256": "6b2793bbd5690e8dcb9c47bdd62485e6b7ab0ece69cb00d89100f06149c30e84" }, "downloads": -1, "filename": "django-user_agents-0.3.0.tar.gz", "has_sig": false, "md5_digest": "d56d5f15da833826df9cb0a4d760e394", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6268, "upload_time": "2014-08-24T08:32:20", "url": "https://files.pythonhosted.org/packages/ef/16/f8e6fc54b31572c0b6d148c7351ab2fab5b654d6b3a76bc5482e1501038c/django-user_agents-0.3.0.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "aa6854102c1a89aca78c45d8a2c30c90", "sha256": "c5d3d827ea86ed0971b7e344bf8f97ce46a41ccb3ab479c1aef12930bf6ac058" }, "downloads": -1, "filename": "django_user_agents-0.3.2-py2-none-any.whl", "has_sig": false, "md5_digest": "aa6854102c1a89aca78c45d8a2c30c90", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 11226, "upload_time": "2017-08-08T05:04:24", "url": "https://files.pythonhosted.org/packages/57/b9/bf46352830861c315b693887b23a5a61f7f3cbc1d197cace8035f18b288e/django_user_agents-0.3.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "57e5284b8545f75db34d2d99c156e488", "sha256": "72b1d8f10eebf88c6c04548668ca06c3d4392b1de79dd2a5cf3da7bc5f3027b6" }, "downloads": -1, "filename": "django-user_agents-0.3.2.tar.gz", "has_sig": false, "md5_digest": "57e5284b8545f75db34d2d99c156e488", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7104, "upload_time": "2017-08-08T05:04:22", "url": "https://files.pythonhosted.org/packages/2d/4f/b996e7e47bc62799ad065cfcf50c2b79256ded0c44c21196e256feb4e16e/django-user_agents-0.3.2.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "545c77925ad1542437392957ac50d7ce", "sha256": "cd9d9f7158b23c5237b2dacb0bc4fffdf77fefe1d2633b5814d3874288ebdb5d" }, "downloads": -1, "filename": "django_user_agents-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "545c77925ad1542437392957ac50d7ce", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8616, "upload_time": "2019-06-22T13:33:48", "url": "https://files.pythonhosted.org/packages/6c/a3/31b2728702f13328cc65d6c8ed652ad8125a9a71489e445c11f188b39f79/django_user_agents-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36fa2bb89131533ec4bd82c948fd30a6", "sha256": "cda8ae2146cee30e6867a07943f56ecc570b4391d725ab5309901a8b3e4a3514" }, "downloads": -1, "filename": "django-user_agents-0.4.0.tar.gz", "has_sig": false, "md5_digest": "36fa2bb89131533ec4bd82c948fd30a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8501, "upload_time": "2019-06-22T13:33:50", "url": "https://files.pythonhosted.org/packages/37/f2/dd96cc880d7549cc9f67c8b1ad8e6695f9731658fdf8aa476f0bcb9c89c7/django-user_agents-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "545c77925ad1542437392957ac50d7ce", "sha256": "cd9d9f7158b23c5237b2dacb0bc4fffdf77fefe1d2633b5814d3874288ebdb5d" }, "downloads": -1, "filename": "django_user_agents-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "545c77925ad1542437392957ac50d7ce", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8616, "upload_time": "2019-06-22T13:33:48", "url": "https://files.pythonhosted.org/packages/6c/a3/31b2728702f13328cc65d6c8ed652ad8125a9a71489e445c11f188b39f79/django_user_agents-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36fa2bb89131533ec4bd82c948fd30a6", "sha256": "cda8ae2146cee30e6867a07943f56ecc570b4391d725ab5309901a8b3e4a3514" }, "downloads": -1, "filename": "django-user_agents-0.4.0.tar.gz", "has_sig": false, "md5_digest": "36fa2bb89131533ec4bd82c948fd30a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8501, "upload_time": "2019-06-22T13:33:50", "url": "https://files.pythonhosted.org/packages/37/f2/dd96cc880d7549cc9f67c8b1ad8e6695f9731658fdf8aa476f0bcb9c89c7/django-user_agents-0.4.0.tar.gz" } ] }