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).
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-agentsuv
uv add django-user-agentspoetry
poetry add django-user-agentsInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
user-agentsParses browser user agent strings to identify…
permissive · top 5,000 on PyPI
pymobiledetectDetects mobile phones and tablets from HTTP…
agpl · top 15,000 on PyPI
device-detectorParses user agent strings and client hints to…
unclear · top 15,000 on PyPI
httpagentparserParses HTTP User-Agent strings to extract and…
unclear · top 15,000 on PyPI
ua-parserParses user-agent strings to extract browser,…
permissive · top 1,000 on PyPI
fake-useragentGenerates random or browser-specific user-agent…
permissive · top 5,000 on PyPI
ua-parser-rsProvides a Rust-accelerated user-agent parser…
permissive · top 5,000 on PyPI
random-user-agentProvides random user agent strings filtered by…
permissive · top 15,000 on PyPI
browserforgeGenerates realistic browser headers and device…
permissive · top 5,000 on PyPI
ua-generatorGenerates realistic, randomized user-agent…
permissive · top 5,000 on PyPI