skillfed

django-user-agents

A django package that allows easy identification of visitors' browser, operating system and device information (mobile phone, tablet or has touch capabilities).

django-user-agents v0.4.0 793.3K downloads/30d#5,042 on PyPI648
Permissive license MIT Abandoned released

What it is and what it does

django-user-agents is a Django middleware and utility package that wraps user-agents to parse HTTP User-Agent headers and expose device, browser, and OS information on each request. It adds a user_agent attribute to the request object, allowing you to check properties like is_mobile, is_tablet, is_touch_capable, is_pc, and is_bot, plus access detailed browser family and version, OS family and version, and device family. The package also provides template filters and a utility function for use in views.

The package depends on django and user-agents as runtime dependencies. It supports optional caching via Django's cache framework to avoid re-parsing the same User-Agent strings. However, the package has been abandoned since 2019—no releases or commits for several years—and its classifiers reflect Python 2.7 and Python 3.4–3.7, all now end-of-life. Using it on modern Python or Django versions carries risk of undetected incompatibilities.

Use it for:

  • Serve different HTML or CSS to mobile visitors versus desktop users without JavaScript detection.
  • Log or track device type (phone, tablet, PC) for analytics or user behavior studies.
  • Conditionally render touch-friendly UI components in templates when is_touch_capable is true.
  • Block or flag bot traffic by checking is_bot in middleware or views.
  • Adapt API responses or content based on device capabilities detected from User-Agent.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses HTTP User-Agent headers in Django to identify visitor browser, OS, device type, and capabilities like mobile or touch support.

No—not without caution. The package is abandoned (last release 2019-06-22, last commit 2021-09-02) and its classifiers only cover Python 2.7 and 3.4–3.7, all end-of-life. Compatibility with modern Django and Python is unverified. For new projects, consider a maintained alternative or verify that the upstream user-agents library is still actively updated before committing.

Install

django-user-agents on PyPI

pip

pip install django-user-agents

uv

uv add django-user-agents

poetry

poetry add django-user-agents

Installing django-user-agents

Before you install

Low friction install with just two runtime dependencies. However, the package is abandoned—last release was 2019-06-22 and last commit 2021-09-02. Classifiers list Python 2.7 and Python 3.4–3.7, which are now end-of-life; compatibility with modern versions is unverified.

License in practice

MIT license (permissive) places no restrictions on use, modification, or distribution in your own projects.

Quickstart

pip install django-user-agents

# In settings.py
INSTALLED_APPS = ['django_user_agents']
MIDDLEWARE_CLASSES = ['django_user_agents.middleware.UserAgentMiddleware']

# In views.py
def my_view(request):
    if request.user_agent.is_mobile:
        # Handle mobile visitor

Requires django and user-agents to be installed first. Optional but recommended: a cache backend configured in Django settings to speed up parsing.

Verify before relying

  • Compatibility with Django versions released after 2.2.
  • Compatibility with Python versions after 3.7.
  • Whether the underlying user-agents library is still maintained and receives UA database updates.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 2 — django, user-agents
Maintenance abandoned — 2,610 days since the last release
Last repo commit
First released
Downloads 793,298/month — #5,042 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_user_agents-0.4.0-py3-none-any.whl

Development Status :: 4 - BetaEnvironment :: Web EnvironmentFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python Modules

Tags

django user agent detectionbrowser os device identificationmobile tablet detection djangouser agent parsing middlewarevisitor device classification
device-detectionmiddlewareabandoned

More Python Modules packages