
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
djangorestframework-xml
Advanced tools
XML support for Django REST Framework
Full documentation for the project is available at http://jpadilla.github.io/django-rest-framework-xml.
XML support extracted as a third party package directly from the official Django REST Framework implementation. It requires the defusedxml package only because it safeguards against some security issues that were discovered.
Note: XML output provided is an ad-hoc format that isn't formally described. If you have specific XML requirements you'll need to write your own XML parsers/renderers in order to fully control the representation.
Install using pip
...
$ pip install djangorestframework-xml
REST_FRAMEWORK = {
'DEFAULT_PARSER_CLASSES': (
'rest_framework_xml.parsers.XMLParser',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework_xml.renderers.XMLRenderer',
),
}
You can also set the renderer and parser used for an individual view, or viewset, using the APIView class based views.
from rest_framework import routers, serializers, viewsets
from rest_framework_xml.parsers import XMLParser
from rest_framework_xml.renderers import XMLRenderer
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'is_staff')
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
parser_classes = (XMLParser,)
renderer_classes = (XMLRenderer,)
<?xml version="1.0" encoding="utf-8"?>
<root>
<list-item>
<url>http://127.0.0.1:8000/users/1/.xml</url>
<username>jpadilla</username>
<email>jpadilla@example.com</email>
<is_staff>True</is_staff>
</list-item>
</root>
Full documentation for the project is available at http://jpadilla.github.io/django-rest-framework-xml.
You may also want to follow the author on Twitter.
FAQs
XML support for Django REST Framework
We found that djangorestframework-xml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.