Simple and powerful RPC server for your Django project
Project description
django-modern-rpc
Embed an XML-RPC / JSON-RPC server in your Django project!
Main features
- XML-RPC and JSON-RPC 2.0 support (JSON-RPC 1.0 is NOT supported)
- Custom authentication process
- Custom rror handling
- Sync and async procedures
- Multiple servers
- Customizable XML / JSON backends with builtin support for orjson, rapidjson, lxml, etree, etc.
Requirements
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 | 3.14 |
|---|---|---|---|---|---|---|---|
| Django 3.2 | 🟢 | 🟢 | 🟢 | 🔴 | 🔴 | 🔴 | 🔴 |
| Django 4.0 | 🟢 | 🟢 | 🟢 | 🔴 | 🔴 | 🔴 | 🔴 |
| Django 4.1 | 🟢 | 🟢 | 🟢 | 🟢 | 🔴 | 🔴 | 🔴 |
| Django 4.2 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🔴 | 🔴 |
| Django 5.0 | 🔴 | 🔴 | 🟢 | 🟢 | 🟢 | 🔴 | 🔴 |
| Django 5.1 | 🔴 | 🔴 | 🟢 | 🟢 | 🟢 | 🟢 | 🔴 |
| Django 5.2 | 🔴 | 🔴 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
| Django 6.0 | 🔴 | 🔴 | 🔴 | 🔴 | 🟢 | 🟢 | 🟢 |
To enforce security, defusedxml will be installed as a dependency.
Quickstart
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
# Alternatively, you can use the asynchronous view:
# path('rpc/', server.async_view),
]
The server's view is already configured with CSRF exemption and POST-only restrictions.
Code quality
The project uses nox as a task runner to launch tests suite against all supported Python / Django combinations and generate a coverage report file. Ruff is used to lint and format the codebase, and mypy is used to perform type checking.
All these tools are automatically run in various GitHub Actions workflows, and external tools are used to perform static code analysis and collect coverage results.
SonarQube
Codacy
Coveralls
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_modern_rpc-2.0.0.tar.gz.
File metadata
- Download URL: django_modern_rpc-2.0.0.tar.gz
- Upload date:
- Size: 29.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3c80daacad806fcff50447aacf8e70cc91bae5914ec48e9a9ea56bd5a38787e
|
|
| MD5 |
6451785d7135cec48093f7cf5177d2f1
|
|
| BLAKE2b-256 |
1fb9ece75316067f7c7ecbdb0cac50cea6ba48e6c6a810065fe7df2a81bd18e7
|
File details
Details for the file django_modern_rpc-2.0.0-py3-none-any.whl.
File metadata
- Download URL: django_modern_rpc-2.0.0-py3-none-any.whl
- Upload date:
- Size: 43.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dc5af87a21cc94f94060d789f77d522cadb4ec5f3994d9bdd6921ea32b11152
|
|
| MD5 |
a66a9a6a805e65fb67ae34b2ed1752d4
|
|
| BLAKE2b-256 |
f1a60fd8fde626af30c90c7467e698a1a284e1b5feb8588c8a8459429f2a07f6
|