Django-modern-rest 0.16.0 release

Open in a window
Article news.ycombinator.com

Django-modern-rest 0.16.0 release

Hi everyone, I am the release manager of `django-modern-rest` :)

django-modern-rest 0.16.0 is out!

Is this your first time that you hear about this project? django-modern-rest is a fully typed / fast / flexible / async-ready framework to create REST APIs for Django. It supports Pydantic, msgspec, attrs and many other models.

Here's how the code looks like:

    import uuid
    import pydantic
    from dmr import Body, Controller
    from dmr.plugins.pydantic import PydanticFastSerializer

    class UserCreateModel(pydantic.BaseModel):
        email: str

    class UserModel(UserCreateModel):
        uid: uuid.UUID

    class UserController(Controller[PydanticFastSerializer]):
        def post(self, parsed_body: Body[UserCreateModel]) -> UserModel:
            return UserModel(uid=uuid.uuid4(), email=parsed_body.email)
Other notable features:

- Builtin auth with sessions / JWT headers and cookies

- Validation of requests and responses according to the OpenAPI spec in debug mode, the spec is the source of truth

- Builtin content negotiation, supporting conditional request and response models for different content types

- Flexible error handling

- Optional error model negotiation and complete customization

- Streaming of SSE and JsonLines

- Code reuse is the first-class citizen, create your own typed abstractions and use them with ease and safety

- Advanced testing strategies, including OpenAPI coverage testing and property based tests with the help of schemathesis

- AI as the first-class feature: skills, contexts, mcps, etc. But, no slop inside.

- Repo: https://github.com/wemake-services/django-modern-rest

- Docs: https://django-modern-rest.readthedocs.io

Now, back to the 0.16.0 release!

Built during `opensource_september` community event with 32 contributors and 144 commits. This is our fastest release ever.

## Performance

- PydanticFastSerializer: deserialize x2.2, serialize x1.33 faster

- New BodyMsgspec component: decodes request bytes straight into a msgspec.Struct, x1.6 faster than Body

- msgspec request context validation x2 faster

- Content negotiation is memoized per header: up to x65 faster for browser-style Accept headers

- msgspec 0.22.0, cheaper checks, cookies, headers, and responses

## Features

- Default values for components: Body[Model | None] = None just works

- concrete_views for JWT, token, and session auth: a login route in one line of urls.py, zero view code

- Cursor (keyset) pagination with sync and async APIs

- `extras=` for your own typed `@modify` / `@validate` parameters

- PEP 696 TypeVar defaults for reusable controllers

- First-class CSRF: proper 403 specs and REST error responses

- external_re_path and nested external_path

- Error handlers can re-raise a new error for the next layer

- OpenAPI: x-extensions on every object, security for gateways and mTLS, OpenAPI 3.2 fields, controller-level tags/deprecated/servers, deterministic schema output

## One rule for all config

Settings are no longer merged across levels. Endpoint overrides controller, controller overrides settings. Explicit [] or None disables, EMPTY falls through. Merge explicitly when you want it: `@modify(auth=[*auth, other])`.

## AI tooling

Agent skills now ship inside the package: uvx library-skills installs the ones matching your version. The new `$dmr-upgrade` skill carries the migration prompts, so ask your coding agent to upgrade you from 0.15.0. Every docs page is also served as Markdown.

- Repo: https://github.com/wemake-services/django-modern-rest

- Docs: https://django-modern-rest.readthedocs.io

- Changelog: https://github.com/wemake-services/django-modern-rest/blob/master/CHANGELOG.md

- Full release notes: https://github.com/wemake-services/django-modern-rest/releases/tag/0.16.0

Discussion 0 comments · 5 points · sobolevn · 14h
Open on HN
Loading the discussion…

Domain filters

Stories from these domains are hidden from every list. Subdomains match too: blocking substack.com also hides danluu.substack.com. The list is kept in this browser only.

Help

Keyboard

j / k
Move down and up the story list. The arrow keys scroll whatever has focus.
Enter
Read the marked story in the article reader.
]
Read the next story in the same article-reader applet. Back returns to the previous story.
p
Pin or unpin the marked story, which keeps it in Pinned.
n / N
Move to the next or previous top-level comment in the window in front.
c
Collapse or expand that comment.
f
Hide or show the story list.
Esc
Close a menu or this help.
Access key m
Go to the menu bar. Most browsers take it with Alt on Windows and Linux, and Safari with Control and Option.
?
Show this help.

Windows

Each story opens in a window holding its article above its discussion; drag the bar between them to share the room differently. A window can be moved by its title bar, resized from any edge, snapped to a half or a corner by dragging it there, maximised, or minimised to the bar at the foot of the page. Use Window > New reader window to open an empty reader, or a story row's Open in new reader window button to compare articles. Docked readers keep their articles when you select another story from the sidebar. Minimized readers can be restored and reused for their site. A window's Next story link reads on down the list in the same window.

A link in a comment or an article to another Hacker News or Lobsters thread opens that thread in a window too. A link to a single HN comment opens the comment above its replies.

While a story's window is in front, the Story and Discussion menus in the menu bar hold its commands: pinning, Next story, sorting, collapsing every thread, jumping to the first new comment. Each window also remembers where you were in its article and discussion, so a reload, or Back to a story that Next took you past, finds your place again. Closing a window forgets it.

The whole arrangement lives in the address, so a bookmark or a shared link brings it back, and Back undoes the last change. Moving between Hacker News, Lobsters, their lists, Pinned and Find changes only the list, and leaves the windows open.

The list

The pin at the start of a row keeps the story in Pinned, and the cross at its end hides it. Pinned can be narrowed by words in the title, site or author, by source, and to the stories you haven't opened yet, and ordered by when you pinned them, by points or by comments; the filters are part of the address, so a filtered view can be bookmarked. Scroll past the end of the list to load more. Domain filters, in the View menu, hide every story from a site.

Applets

The Applets menu in the menu bar holds three tools, each a window of its own. Replies to me takes your Hacker News user name and lists the replies to your last thirty comments and stories, checking again every three minutes while it is open, and marking what is new since you last marked them read. Look up a user opens a profile on Hacker News or Lobsters, with their submissions and recent comments, as a commenter's name in any discussion does; the bar at the top of a profile looks up someone else in the same window, and Back returns to the one before. Who is hiring? filters the posts of HN's monthly hiring threads by the words you type.

They read only what the sites publish to everyone, so none of them asks for a login, and your user name stays in this browser.

Find

Find takes any link and lists every time it was submitted to Hacker News and Lobsters, so you can read each discussion of it.

About

YAVCHN never sees your Hacker News or Lobsters login. The discussion is fetched from each site's public API; to vote or reply, follow the link above the discussion, or the arrow beside a comment, to the source's own site. Pins, hidden stories, filters and layout are kept in this browser only.

Open source: github.com/paulmooreparks/yavchn. Built with PUDL.