Configuring django-modern-rpc is quick and simple. Follow that steps to be up and running in few minutes!
Installation and configuration¶
Use your preferred tool (pip, pipenv, pipsi, easy_install, requirements.txt file, etc.) to install package
django-modern-rpc in your environment:
pip install django-modern-rpc
modernrpc app to your Django applications, in
# in project's settings.py INSTALLED_APPS = [ ... 'modernrpc', ]
Declare a RPC Entry Point in URLConf¶
The entry point is a standard Django view class which mainly handle RPC calls. Like other Django views, you have
django.conf.urls.url() to map URL pattern with this class. This can be done in your project’s URLConf,
or in any app specific one.
# In myproject/my_app/urls.py from django.conf.urls import url from modernrpc.views import RPCEntryPoint urlpatterns = [ # ... other url patterns url(r'^rpc/', RPCEntryPoint.as_view()), ]
Entry points behavior can be customized to your needs. Read Entry point configuration for full documentation.
Write and register your remote procedures¶
Now, you have to write your remote procedures. These are global functions decorated with
# In myproject/rpc_app/rpc_methods.py from modernrpc.core import rpc_method @rpc_method def add(a, b): return a + b
@rpc_method behavior can be customized to your needs. Read Configure the registration
for full list of options.
Declare your RPC methods modules¶
Django-modern-rpc will automatically register functions decorated with
@rpc_method, but needs a hint to locate them.
settings.MODERNRPC_METHODS_MODULES to indicate all python modules where remote procedures are defined.
MODERNRPC_METHODS_MODULES = [ 'rpc_app.rpc_methods' ]
That’s all !¶
Your application is ready to receive XML-RPC or JSON-RPC calls. The entry point URL is
but you can customize it to fit your needs.