djangorestframework-xml
XML support for Django REST Framework
What it is and what it does
djangorestframework-xml is a third-party package that extends Django REST Framework with XML content-type support. It provides XMLParser and XMLRenderer classes that allow your REST API endpoints to accept XML request bodies and return XML responses, integrated directly into Django REST Framework's serialization pipeline. The package uses defusedxml under the hood to guard against XML security vulnerabilities.
The XML output format is not formally specified—it's a simple ad-hoc representation of your serialized data. If you need strict control over XML structure, namespaces, or schema compliance, you'll need to write custom XML parsers and renderers. The package is stable and permissively licensed, but dormant since 2020, so you should verify it works with your current Django and DRF versions before adopting it.
Use it for:
- Add XML endpoint support to an existing Django REST Framework API that primarily serves JSON but needs to support legacy XML-consuming clients.
- Parse incoming XML payloads in API requests when clients cannot send JSON.
- Expose API data in both JSON and XML formats by configuring different renderers per view or globally.
- Migrate from an older XML-based API to Django REST Framework while maintaining XML compatibility during a transition period.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds XML parsing and rendering support to Django REST Framework, allowing APIs to accept and return XML-formatted data alongside the framework's standard JSON handling.
Yes, if you need XML support in Django REST Framework and can verify compatibility with your current Django and DRF versions. The low install friction, permissive license, and lack of known vulnerabilities make it a reasonable choice. However, the dormant maintenance status (last release 2020-04-12) means you should test thoroughly in your environment and be prepared to fork or write custom XML handling if issues arise with newer Django or DRF releases.
Install
djangorestframework-xml on PyPI
pip
pip install djangorestframework-xmluv
uv add djangorestframework-xmlpoetry
poetry add djangorestframework-xmlInstalling djangorestframework-xml
Before you install
Low install friction with a single runtime dependency. The package is dormant—last release was 2020-04-12, with no commits since 2023-09-18. It remains marked Production/Stable and supports current Python versions, but you should verify compatibility with your specific Django and Django REST Framework versions before relying on it.
License in practice
BSD permissive license means you can use this freely in commercial and open-source projects with minimal restrictions, provided you include the license text.
Quickstart
pip install djangorestframework-xml
# In Django settings.py
REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': ('rest_framework_xml.parsers.XMLParser',),
'DEFAULT_RENDERER_CLASSES': ('rest_framework_xml.renderers.XMLRenderer',),
}
Requires Python 3.5+, Django 2.2+, and Django REST Framework 3.11+. The XML output format is ad-hoc and not formally specified; custom parsers/renderers may be needed for specific XML requirements.
Verify before relying
- Compatibility with Django and Django REST Framework versions released after 2020-04-12.
- Whether the ad-hoc XML format meets your specific XML schema or validation requirements.
- Current status of defusedxml dependency and any security updates it may require.
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — defusedxml |
| Maintenance | dormant — 2,315 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 533,927/month — #6,139 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: djangorestframework_xml-2.0.0-py2.py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
django-tastypiedjango-tastypie provides a REST API framework…
permissive · top 15,000 on PyPI
djangorestframeworkBuilds web APIs on top of Django with…
permissive · top 1,000 on PyPI
djangorestframework-csvAdds CSV rendering and parsing capabilities to…
permissive · top 5,000 on PyPI
djangorestframework-yamlAdds YAML parsing and rendering support to…
permissive · top 15,000 on PyPI
djangorestframework-camel-caseConverts JSON field names between camelCase and…
permissive · top 15,000 on PyPI
drf-orjson-rendererProvides a high-performance JSON renderer and…
permissive · top 15,000 on PyPI
djangorestframework-role-filtersAdds role-based access control to Django REST…
permissive · top 5,000 on PyPI
drf-extra-fieldsProvides specialized serializer fields for…
permissive · top 15,000 on PyPI
drf-rw-serializersExtends Django REST Framework with separate…
permissive · top 15,000 on PyPI
defusedxmlDefusedxml hardens Python's standard XML…
permissive · top 1,000 on PyPI