Skip to main content

unrest_api

Lightweight Django utilities for building JSON APIs - schema-driven form views, auth endpoints, user-settings scaffolding, and helpful middleware.

Install

pip install unrest_api

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "unrest_api",
]

Features

  • unrest_api.schema.schema_form — turn a ModelForm into a JSON CRUD endpoint (GET schema, POST create, PUT partial update, DELETE).
  • unrest_api.schema.UnrestForm — ModelForm base that exposes self.request so __init__, clean, and save can scope querysets and defaults to the current user.
  • unrest_api.urls — drop-in auth routes (login, logout, register, settings).
  • unrest_api.models.AbstractUserSettings — abstract base providing timezone and theme plus the OneToOneField to AUTH_USER_MODEL (related_name='settings').
  • unrest_api.middleware.Json404Middleware — converts Http404 raised under an API prefix into JsonResponse({'error': ...}, status=404).

Quick start

# urls.py
from django.urls import include, path

urlpatterns = [
    path("api/auth/", include("unrest_api.urls")),
]
# forms.py
from unrest_api.schema import UnrestForm, register
from .models import Widget

@register
class WidgetForm(UnrestForm):
    class Meta:
        model = Widget
        fields = ["name", "color"]

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # self.request is available here

Settings

Setting Default Description
UNREST_USER_SETTINGS_FORM None Dotted path to a ModelForm for project-specific fields exposed by the unified settings endpoint.
UNREST_JSON_404_PREFIX "/api/" URL prefix under which Json404Middleware converts Http404 to JSON.

Compatibility

  • Python 3.11+
  • Django 5.2+

Changelog

See CHANGELOG.md.

License

MIT

Metadata

Release files for unrest-api 0.4.0

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

Source distribution (sdist)

Source distribution for unrest-api 0.4.0
File Size Uploaded Provenance
unrest_api-0.4.0.tar.gz 23.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for unrest-api 0.4.0
File Interpreter ABI Platform
unrest_api-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.3 kB

Release files / unrest_api-0.4.0.tar.gz

Download URL unrest_api-0.4.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b977e2f8e065de1feb59e383601379aa95755783fed44f63e5626ad85a97e9a8
BLAKE2b-256 checksum
How to use checksums
252838f0d9a556aad958ae877806531ddf08afbf87a78ba66de089ac166da889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / unrest_api-0.4.0-py3-none-any.whl

Download URL unrest_api-0.4.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
454c92475232e9605606d222b0c9a5f9b27b6256e5f323f8edaac7b377cc5f90
BLAKE2b-256 checksum
How to use checksums
acc26adfef1b7e9fc9fd84a7493d5a59dbb10d6668b8be8339df58a0e5910bac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Security for unrest-api 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files No provenance

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