TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Django Ninja – Fast Django REST Framework for Building APIs

169 点作者 watchdogtimer超过 3 年前

8 条评论

samwillis超过 3 年前
This has an explanation of the motivation for this project:<p><a href="https:&#x2F;&#x2F;django-ninja.rest-framework.com&#x2F;motivation&#x2F;" rel="nofollow">https:&#x2F;&#x2F;django-ninja.rest-framework.com&#x2F;motivation&#x2F;</a><p>It sounds super interesting, it fits the middle ground between Django Rest Framework and FastAPI taking the best of both. Full support for Django and particularly it’s ORM (hard to do with FastAPI as the Django ORM is not yet async and can’t be used with FastAPI)<p>I like that it supports both sync and async as I’m personally not convinced about the use of async Python everywhere. I could see this being brilliant for an api where the majority is simple sync code but with a few endpoint with long running responses or where you need multiple concurrent requests to DBS or other APIs.<p>(Edited for clarity, thanks vladvasiliu)
评论 #30223288 未加载
fredrikholm超过 3 年前
&gt; FAST execution: Very high performance thanks to Pydantic and async support.<p>&gt; Benchmark: 750 requests per second.<p>Think we&#x27;re gonna need a couple of zeroes on that number to throw around words like &quot;very high performance&quot;.
评论 #30233062 未加载
IgorPartola超过 3 年前
The approach for this I have taken lately is this:<p>1. A custom made serializer. This is the most complicated 150 lines of code in that it can traverse Django ORM objects&#x2F;query sets and output them to JSON. It supports explicit included and excluded fields and included relationships which it automatically prefetches.<p>2. Custom middleware that parses any application&#x2F;json request bodies in <i>request.data</i>.<p>3. I use Django forms on any data going from client to server for validation. Works great, no reason to make this complicated.<p>That’s it. Now I can have a REST API written as normal Django views. It is significantly more performant Thant DRF since it doesn’t need to check for a whole lot of different complicated field types when serializing. It’s easy to understand (just call <i>serialize(users, excluded_fields=[“password”], relationships=[“books.chapters”])</i> to return JSON to the client; you can also annotate your models to include&#x2F;exclude fields and relationships by default). It has validation errors built in via Django forms. It just works.
评论 #30224790 未加载
评论 #30228865 未加载
dplgk超过 3 年前
Nice to have a simpler option than DRF which has grown into a quite complicated mound of code.
评论 #30225506 未加载
评论 #30223389 未加载
评论 #30224955 未加载
评论 #30229657 未加载
bluewalt超过 3 年前
This project is very clever, because as a Django developer, when I tried to use. FastAPI, I didn&#x27;t get the faith to learn another ORM.<p>I&#x27;ve been using django ninja for months and I can say that it&#x27;s a very good replacement to DRF. It&#x27;s way simpler to use and less bloated, thanks to pydantic.<p>However I would not use it for important projects in production, because of a lack of support and documentation, and the fact that it relies almost entirely on a single developer (like many other projects, right).
todotask超过 3 年前
When I read the tutorial and run on uvicorn with my lack of experience in Python language, it&#x27;s significantly slow (3,000+ rps using this framework manage.py vs &lt;500 rps on uvicorn)?
nesarkvechnep超过 3 年前
Unfortunately, it doesn&#x27;t enforce usage of hypertext.
frays超过 3 年前
Will check this out. Thanks for sharing.