{ "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.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "fixed middleware problem from original\n\nDjango 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-useragents``, 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'\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 {% 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 {% 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.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": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/papenx/django-user_agents", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-useragents", "package_url": "https://pypi.org/project/django-useragents/", "platform": "", "project_url": "https://pypi.org/project/django-useragents/", "project_urls": { "Homepage": "https://github.com/papenx/django-user_agents" }, "release_url": "https://pypi.org/project/django-useragents/0.3.1/", "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.3.1" }, "last_serial": 3072750, "releases": { "0.3.1": [ { "comment_text": "", "digests": { "md5": "3773aba85aade80911cf213837848750", "sha256": "f82d623059bc18091da9481214eebe2985390ece9cb65c16bbd7caa5cf53b483" }, "downloads": -1, "filename": "django_useragents-0.3.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3773aba85aade80911cf213837848750", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11056, "upload_time": "2017-08-04T14:03:07", "url": "https://files.pythonhosted.org/packages/0f/8a/f705269c4ba18a363b12dda6da4b39746651eb114dc07fe5cd09dcec3cf4/django_useragents-0.3.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0b3f37eb0dec0a42f08b3de827f45c46", "sha256": "6d7160f9d9183473bbfab48c227e21965103ce4906623c176b2ecb6ac7ae257a" }, "downloads": -1, "filename": "django-useragents-0.3.1.0.tar.gz", "has_sig": false, "md5_digest": "0b3f37eb0dec0a42f08b3de827f45c46", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8765, "upload_time": "2017-08-04T14:03:11", "url": "https://files.pythonhosted.org/packages/8a/68/3be25d9e97e7f48c467b84ce5ec057c6cb9c8faf9c407e4034cd61ad185e/django-useragents-0.3.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3773aba85aade80911cf213837848750", "sha256": "f82d623059bc18091da9481214eebe2985390ece9cb65c16bbd7caa5cf53b483" }, "downloads": -1, "filename": "django_useragents-0.3.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "3773aba85aade80911cf213837848750", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 11056, "upload_time": "2017-08-04T14:03:07", "url": "https://files.pythonhosted.org/packages/0f/8a/f705269c4ba18a363b12dda6da4b39746651eb114dc07fe5cd09dcec3cf4/django_useragents-0.3.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0b3f37eb0dec0a42f08b3de827f45c46", "sha256": "6d7160f9d9183473bbfab48c227e21965103ce4906623c176b2ecb6ac7ae257a" }, "downloads": -1, "filename": "django-useragents-0.3.1.0.tar.gz", "has_sig": false, "md5_digest": "0b3f37eb0dec0a42f08b3de827f45c46", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8765, "upload_time": "2017-08-04T14:03:11", "url": "https://files.pythonhosted.org/packages/8a/68/3be25d9e97e7f48c467b84ce5ec057c6cb9c8faf9c407e4034cd61ad185e/django-useragents-0.3.1.0.tar.gz" } ] }