Simple XML-RPC and JSON-RPC server for modern Django
Embed an XML-RPC and/or JSON-RPC server in your Django project!
The following Django / Python versions are supported, according to Django Installation FAQ
Python β | 3.8 | 3.9 | 3.10 | 3.11 | 3.12 | 3.13 |
---|---|---|---|---|---|---|
Django 3.2 | π’ | π’ | π’ | π΄ | π΄ | π΄ |
Django 4.0 | π’ | π’ | π’ | π΄ | π΄ | π΄ |
Django 4.1 | π’ | π’ | π’ | π’ | π΄ | π΄ |
Django 4.2 | π’ | π’ | π’ | π’ | π’ | π΄ |
Django 5.0 | π΄ | π΄ | π’ | π’ | π’ | π΄ |
Django 5.1 | π΄ | π΄ | π’ | π’ | π’ | π’ |
Django 5.2 | π΄ | π΄ | π’ | π’ | π’ | π’ |
To enforce security, defusedxml will be installed as a dependency.
Install django-modern-rpc
in your environment
pip install django-modern-rpc
Create an RpcServer
instance and register your first procedure, in myapp/rpc.py
from modernrpc.server import RpcServer
server = RpcServer()
@server.register_procedure
def add(a: int, b: int) -> int:
"""Add two numbers and return the result.
:param a: First number
:param b: Second number
:return: Sum of a and b
"""
return a + b
Configure a path to allow RPC clients calling your procedures, in urls.py
from django.urls import path
from myapp.rpc import server
urlpatterns = [
# ... other url patterns
path('rpc/', server.view), # Synchronous view
]
The serverβs view is already configured with CSRF exemption and POST-only restrictions.
The projects uses nox as a task runner to launch tests suite with all supported Python / Django combinations. In
addition, ruff is used to lint and format the codebase and mypy is used to perform type checking.
All these tools are run automatically in various GitHub Actions workflows and to upload coverage results and static
code analysis reports to the following tools.