---
title: "Moving from Django DRF to Ninja API / Pydantic"
description: "Kogan.com is shifting its Django APIs from Django REST Framework's serializers, viewsets and routers to Django Ninja with Pydantic schemas, defining each endpoint as a type-hinted function with separate input Schema and output ModelSchema classes."
url: "https://swe.quest/articles/moving-from-django-drf-to-ninja-api-pydantic-5c19c7648312be77"
canonical: "https://devblog.kogan.com/blog/moving-from-django-drf-to-ninja-api-pydantic"
source: "Kogan.com Dev Blog"
published: "2025-11-10"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["python","api-design","refactoring"]
---

# Moving from Django DRF to Ninja API / Pydantic

A post on [Kogan.com Dev Blog](https://swe.quest/sources/kogan.md), published 2025-11-10, 8 min read, Case study. Original: [https://devblog.kogan.com/blog/moving-from-django-drf-to-ninja-api-pydantic](https://devblog.kogan.com/blog/moving-from-django-drf-to-ninja-api-pydantic)

## Summary

Kogan.com is shifting its Django APIs from Django REST Framework's serializers, viewsets and routers to Django Ninja with Pydantic schemas, defining each endpoint as a type-hinted function with separate input Schema and output ModelSchema classes. A side-by-side CRUD example for a Product model shows that Ninja requires more explicit endpoint definitions than DRF's auto-generated routes. In return it gives less hidden framework magic, automatic OpenAPI docs, and cleaner separation between API code and business logic. The listed tradeoffs are a learning curve for DRF developers, the need for an iterative migration on large codebases, and DRF's larger plugin ecosystem.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Python](https://swe.quest/tags/python.md) (Languages)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)

## Prerequisites

- Django models
- Django REST Framework ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))
- Python type hints ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))

## Keywords

Django REST Framework, Django Ninja, Pydantic, OpenAPI, FastAPI, Django

## Related posts

- [Moving Railway's Frontend Off Next.js](https://swe.quest/articles/moving-railway-s-frontend-off-next-js-a0f8a20e0dc7a7ef.md): Railway · 2026-04-03 · Medium · 5 min read · Frontend, React, Refactoring & migrations, Build systems, CDN & edge
  Railway migrated its entire production frontend (dashboard, canvas, marketing site, 200+ routes) from the Next.js Pages Router to Vite + TanStack Router/Start in two PRs with zero downtime.
- [How we use GraphQL at Europe's largest fashion e-commerce company](https://swe.quest/articles/how-we-use-graphql-at-europe-s-largest-fashion-e-commerce-company-98c53d6b8b858147.md): Zalando Engineering · 2021-03-03 · Easy · 6 min read · GraphQL, API design, Microservices, E-commerce, Resilience
  Zalando replaced a sprawl of per-page and per-platform Backend-for-Frontend services with a single unified GraphQL API owned via a shared monorepo across 12+ domain teams.
- [Upgrading MLflow Pipelines Across a Python Version Boundary](https://swe.quest/articles/upgrading-mlflow-pipelines-across-a-python-version-boundary-f87d50f5b96a2d6c.md): Zalando Engineering · 2026-10-29 · Medium · 6 min read · ML platforms, Python, Refactoring & migrations
  Upgrading Databricks Runtime from 14.3 (Python 3.10) to 17.3 (Python 3.12) broke loading of registered MLflow models, because cloudpickle embeds Python bytecode that the newer interpreter can't parse.
- [Build Apps in Deno with Frameworks such as React, Vue, Express, and more.](https://swe.quest/articles/build-apps-in-deno-with-frameworks-such-as-react-vue-express-and-more-c17610b126d7b402.md): Deno · 2022-11-16 · Medium · 11 min read · JavaScript, Frontend, React, TypeScript
  Deno 1.28's npm support lets you use npm-distributed frameworks like Express, React and Vue directly via \`npm:\` specifiers.
- [Migrating Shop app from React Native to native](https://swe.quest/articles/migrating-shop-app-from-react-native-to-native-d251eff5b6600925.md): Shopify Engineering · 2026-09-10 · Medium · 6 min read · Mobile, React, AI for coding, Refactoring & migrations, Performance engineering
  Shopify rebuilt the Shop app from React Native into native Swift/SwiftUI and Kotlin/Jetpack Compose in 12 weeks, with coding agents porting features using the existing React Native app as a reference.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
