Skip to main content

DrfXios simplifies communication between frontend and Django Rest Framework API.

Quick start

>>> pip install django-drfxios

settings.INSTALLED_APPS

INSTALLED_APPS = [
    ...
    'drfxios',
    ...
]

settings.py

DRFXIOS_ROUTER_PATH = "<dotted.path.to.router>" # eg "api.urls.router"

context_processors

TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'drfxios.context_processors.drfxios',
                ...
            ],
        },
    },
]

base.html

<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.js"></script>
<script src="https://cdn.jsdelivr.net/npm/url-join@4.0.1/lib/url-join.min.js"></script>
<script src="{% static "drfxios/drfxios.js" %}"></script>

<script>
    dx = new DrfXios('api', {{ DRFXIOS.MODEL_LIST|safe }})
</script>

And you’re ready tu use DrfXios in your templates.

Example:

dx.getModel(<pk>)
dx.createModel(<data:obj>)
dx.deleteModel(<pk>)
dx.getModelList(<filter:obj>)
dx.updateModel(<data:obj>)
dx.patchModel(<data:obj>)

All methods return JavaScript promises so you can use .then, .catch and .finally methods.

Release files for django-drfxios 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-drfxios 0.2
File Size Uploaded
django-drfxios-0.2.tar.gz 3.7 kB Details

Release files / django-drfxios-0.2.tar.gz

Download URL django-drfxios-0.2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
35c89a8814b22dc85968b715ed0c1749b0a70465be194d69040940898df15266
BLAKE2b-256 checksum
How to use checksums
566ee3d5245b667bd336793769224d0807e833b5273e9f4821f9b31a573d1a28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page