---
title: "Django: introducing django-msgspec"
url: https://daily.dev/posts/django-introducing-django-msgspec-cibe2whmz
source_url: https://adamj.eu/tech/2026/08/07/introducing-django-msgspec
type: article
source: "Adam Johnson"
published: 2026-08-07T21:26:14.221Z
updated: 2026-08-07T21:26:49.886Z
tags: ["python", "django"]
reading_time: 8
upvotes: 10
comments: 2
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Django: introducing django-msgspec

**[Adam Johnson](https://daily.dev/sources/adamj)** · 8 min read · 10 upvotes · 2 comments

## Summary

django-msgspec is a new package offering drop-in replacements for Django and Django REST Framework components backed by msgspec, a C-based JSON serialization library that is several times faster than Python's standard library. It provides faster versions of JsonResponse, test client classes, the json_script template tag, session serializer, dumpdata/loaddata serializers, and DRF renderer/parser — most activatable via settings alone with no code changes. The author explains why he chose msgspec over orjson (which he packaged three weeks earlier): orjson has issues with non-string dict keys, 64-bit integer limits, a closed issue tracker, no sub-interpreter support, no free-threading wheels, and trust concerns around maintainer anonymity. msgspec addresses all these points while matching orjson's performance. Known incompatibilities with the standard library include encoding non-finite floats as null and rejecting None/bool dict keys. Future plans include integrating msgspec's typed Struct class for single-pass decode-and-validate workflows.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://adamj.eu/tech/2026/08/07/introducing-django-msgspec>

## Questions this post answers

### What are the main limitations of orjson compared to the Python standard library json module?

orjson requires string dictionary keys (raising TypeError for integer keys unless OPT_NON_STR_KEYS is set), caps integers at 64 bits with no opt-out, has no open issue tracker, does not support Python sub-interpreters at all, publishes no free-threading wheels for Python 3.14, and is maintained pseudonymously with no public engagement channel.

_Developers choosing between JSON libraries for Django projects track trade-offs like these on daily.dev._

### How do I replace Django's default JSON serializer and DRF renderer with msgspec for better performance?

Install django-msgspec and update settings: set SESSION_SERIALIZER to 'django_msgspec.sessions.JSONSerializer', add 'json' and 'jsonl' entries to SERIALIZATION_MODULES pointing to django_msgspec serializers, and set DEFAULT_RENDERER_CLASSES and DEFAULT_PARSER_CLASSES in REST_FRAMEWORK to django_msgspec.rest_framework.JSONRenderer and JSONParser. No application code changes are required.

_Python developers rolling out performance upgrades like this across Django projects find the latest ecosystem moves on daily.dev._

### How does msgspec handle non-finite floats like inf and NaN compared to Python's json module?

msgspec encodes non-finite floats such as float('inf') and float('nan') as null rather than the non-standard Infinity and NaN tokens that Python's standard library emits. This is arguably more correct since Infinity is not valid JSON and many parsers reject it, but it is a breaking change if your code round-trips those values.

_Teams migrating serialization libraries and watching for silent data changes like this rely on daily.dev to stay ahead._

## Community discussion

Top comments from developers on daily.dev.

**@trevorsuna** · 0 upvotes

> Drop-in settings changes make this much easier to evaluate than a large serializer rewrite. I’d put the non-finite float and dictionary-key differences into compatibility tests first; the typed Struct path looks especially compelling once decode and validation can happen in one pass.

**@agustinbarrientos** · 0 upvotes

> For me, a closed issue tracker blocks adoption. Serialization lives on a sensitive boundary, and teams need a public place to audit failures and maintenance risk.

## Similar posts on daily.dev

- [Django: introducing django-orjson](https://daily.dev/posts/django-introducing-django-orjson-5h1b66fxp) · Adam Johnson · 11 upvotes · 1 comments
- [\#489: Or JSON?](https://daily.dev/posts/489-or-json--fp75bcfed) · Planet Python · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#django](https://daily.dev/tags/django)

[View this post on daily.dev](https://daily.dev/posts/django-introducing-django-msgspec-cibe2whmz)
