Releases: vitalik/django-ninja
1.3.0
This version brings few enahcments
- Serialisation context now has request and response code
class SchemaWithCustomSerializer(Schema):
test1: str
test2: str
@model_serializer(mode="wrap")
def ser_model(self, handler, info):
request = info.context["request"] # !!!
response_status = info.context["response_status"] # !!!
return handler(self)
- With
PatchDict
you can quickly define schemas with all optional fields and use it as dict with ONLY fields that were passed in request payload (aka patch requests)
from ninja import PatchDict
class SomeSchema(Schema):
name: str
description: str
due_date: date
# Note all fields a required
@api.patch("/patch")
def modify_data(request, payload: PatchDict[SomeSchema]):
# payload ! <--- payload is a type of dict and contains only keys that were passed in request body (validated with SomeSchema)
for attr, value in payload.items():
setattr(obj, attr, value)
obj.save()
All changes
- Support import string in router.add_router by @martinsvoboda in #1256
- Add default headers for NinjaClientBase instance by @c4ffein in #1259
- Fix issue when consulting request attributes while using mocked request by @acuriel in #1244
- Allow generic filter types by @eugenenelou in #1212
- DRF-style data property for responses in tests by @c4ffein in #1260
- Pass serialisation context to model_dump (fixes #1233) by @scorpp in #1261
- PatchDict util by @vitalik in #1262
New Contributors
- @martinsvoboda made their first contribution in #1256
- @acuriel made their first contribution in #1244
- @eugenenelou made their first contribution in #1212
- @scorpp made their first contribution in #1261
Full Changelog: v1.2.2...v1.3.0
1.2.2
What's Changed
- Fix unchanging field bug when validate assignment true by @austinpgraham in #1232
Full Changelog: v1.2.1...v1.2.2
v1.2.1
1.2.0
What's new
with most notable
- Async Pagination support by @jamesrkiger
- and Throttling
All changes:
- Throttling by @vitalik in #1208
- Async Pagination support by @jamesrkiger in #1030
- Fix ForwardRef._evaluate() missing 1 required keyword-only argument on python 3.12.4 by @Object905 in #1204
- fix: validation of nullable fields with a non-null default value by @julienc91 in #1181
- Add ORM support for SmallAutoField by @jlost in #1185
- Expose django_auth_superuser through all by @mostthingsweb in #992
- Fix dict when validate assignment true by @austinpgraham in #1024
- Fix #1088 : Inconsistency in indentation by @Nirmalkumar6112 in #1091
- Update LimitOffsetPagination.Input schema by @kajiczech in #1134
- Delete setup.py by @jeffwidman in #1138
- chore: modernize ruff config to work with ruff >= v0.2 by @afuetterer in #1120
- chore: update ruff pre-commit version by @afuetterer in #1121
- Minor Typing Improvement for
FilterSchema
by @max-muoto in #1039 - Fix typing for Exception Handlers by @max-muoto in #1130
- Add Generic Typing for
decorate_view
to resolve Pyright Issues by @max-muoto in #1126 - Fix Ninja Schema Typing by @max-muoto in #1165
Docs
- pagination: fix comment about default class by @ivoire in #1034
- Fix typo by @Hisham-Pak in #1054
- docs(form-data): add missing slash by @Zerotask in #1074
- docs(file-uploads): minor adjustments by @Zerotask in #1075
- docs(response): add link for error responses by @Zerotask in #1135
- Fix TestClient name in testing docs by @adriaanwm in #1102
- docs(operations): minor adjustments by @Zerotask in #1076
- Add dark mode to ninja docs by @Hisham-Pak in #1056
- Docs: Adds an example to show how exclude_unset works by @benjaoming in #1173
- fix typo in guides/input/filtering by @Moe-Hassan-123 in #994
- Minor documentation tweaks by @jonklo in #1010
- Cleanup documentation warnings by @jlucas91 in #1021
- Add basic testing documentation by @jlucas91 in #1020
- Fix README.md test badge by @jlucas91 in #1018
- Update django-pydantic-create-schema.md by @pradipthinkitive in #1043
New Contributors
- @mostthingsweb made their first contribution in #992
- @Moe-Hassan-123 made their first contribution in #994
- @jonklo made their first contribution in #1010
- @jlucas91 made their first contribution in #1018
- @austinpgraham made their first contribution in #1024
- @max-muoto made their first contribution in #1039
- @pradipthinkitive made their first contribution in #1043
- @Hisham-Pak made their first contribution in #1054
- @Zerotask made their first contribution in #1074
- @jeffwidman made their first contribution in #1136
- @Nirmalkumar6112 made their first contribution in #1091
- @kajiczech made their first contribution in #1134
- @afuetterer made their first contribution in #1120
- @adriaanwm made their first contribution in #1102
- @benjaoming made their first contribution in #1173
- @Object905 made their first contribution in #1204
- @julienc91 made their first contribution in #1181
- @jlost made their first contribution in #1185
Full Changelog: v1.1.0...v1.2.0
1.1.0
What's Changed
- Pagination set max limit by @HyoungSooo in #915
- Fixed Fields not generated when Meta.fields_optional = 'all' by @vitalik in #986
- Add UUID to supported fields by @gokaykucuk in #982
- Remove Redoc body margin by @Nekidev in #887
- Replace deprecated Pydantic method by @scott-8 in #922
- More comprehensive documentation for CSRF protection by @c4ffein in #906
- Git ignore coverage.xml file by @adamchainz in #944
- Fix pytest.mark.asyncio warning by @adamchainz in #943
- Use ruff to format code instead of black by @jairhenrique in #949
- Attribute
description
declared has typestr
but is used as type None by @luca-digrazia in #530 - Fix test warning by @jairhenrique in #951
- Drop support to unsupported python and django versions by @jairhenrique in #950
- test: Add django 5.0 to the test matrix by @marksweb in #954
- Fix mypy issues by @jairhenrique in #956
- Enable UP rule on ruff by @jairhenrique in #957
- Enable FURB rule on ruff by @jairhenrique in #958
- docs: remove extra backtick in api docs page by @noahgorstein in #964
- Enable PTH rule on ruff by @jairhenrique in #966
- Update ninja conf docs by @jamesrkiger in #972
New Contributors
- @c4ffein made their first contribution in #906
- @adamchainz made their first contribution in #944
- @luca-digrazia made their first contribution in #530
- @Nekidev made their first contribution in #887
- @marksweb made their first contribution in #954
- @noahgorstein made their first contribution in #964
- @HyoungSooo made their first contribution in #915
- @jamesrkiger made their first contribution in #972
- @gokaykucuk made their first contribution in #982
Full Changelog: v1.0.1...v1.1.0
1.0.1
1.0
Read more details and examples here https://django-ninja.dev/whatsnew_v1/
or watch overview video :
Overview
- async authentication fully supported on all layers
- New parameters markers syntax (+
Annotated[]
syntax support) - CSRF is now automatic on Cookie based authentication ( now you should be able to combine multiple cookie/header/etc authenticators and play around with csrf logic)
- Pydantic2 - which has a core re-written in Rust and includes a lot of improvements and features like:
- Safer types.
- Better extensibility.
- Better performance - so far on few projects that I tested getting average 10% speed improvements (some particular views which do lot of validations should get pretty good bumps)
- schema validators/resolvers now have extra context (like request)
- Pagination class accepts a request object
- allow adding routers by string path instead of explicit import
Unfortunately Django ninja integrates very deep into pydantic core with Schema class, so it is not possible to keep both pydantic v1 and v2 supported - and that is why ninja now bumps to version 1 which might have few deprecations or breaking changes on pydantic level
From Django ninja side I tried to make this upgrade as smooth as possible, if you use standard APIs without lot of magic - most likely upgrade should be without any code change
Contributors
@AlTosterino
@AmiZya
@Kristinus
@ddahan
@dipbazz
@ivoire
@lilleswing
@marius-mather
@pavel-beaufort
@pawelngei
@scott-8
@skokado
@vincentdavis
@vpoulailleau
@yasoob
Thank you !
Full Changelog: v0.22.2...v1.0
1.0 RC
What's Changed
- Fixed not awaitable response in async authentication (#44)
This looks like the final pre-release - and I'm happy to report that beta versions was successfully tested by multiple companies in production environments
What's new in 1.x
- async authentication fully supported on all layers
- New parameters markers syntax (+
Annotated[]
syntax support) - CSRF is now automatic on Cookie based authentication ( now you should be able to combine multiple cookie/header/etc authenticators and play around with csrf logic)
- Pydantic2 - which has a core re-written in Rust and includes a lot of improvements and features like:
- Safer types.
- Better extensibility.
- Better performance - so far on few projects that I tested getting average 10% speed improvements (some particular views which do lot of validations should get pretty good bumps)
- schema validators/resolvers now have extra context (like request)
- Pagination class accepts a request object
- allow adding routers by string path instead of explicit import
Unfortunately Django ninja integrates very deep into pydantic core with Schema class, so it is not possible to keep both pydantic v1 and v2 supported - and that is why ninja now bumps to version 1 which might have few deprecations or breaking changes on pydantic level
From Django ninja side I'm trying to make this upgrade as smooth as possible, if you use standard APIs without lot of magic - most likely upgrade should be without any code change
Documentation
- Fix spelling error in motivation documentation by @lilleswing in #874
- Add partial updates and strict validation to the CRUD tutorial by @ddahan in #877
- docs: configure syntax coloring by @ivoire in #878
- docs: use lowercase for language identifier by @ivoire in #879
New Contributors
- @lilleswing made their first contribution in #874
- @ddahan made their first contribution in #877
- @ivoire made their first contribution in #878
Full Changelog: v1.0b2...v1.0rc
1.0 beta2
Warning: This is a pre-release of Django Ninja V1
This is the last change before 1.x release
This version introduces a new cleaner way to mark requests parameters
f.e.
def some_form(request, data: Form[SomeSchema]):
...
instead of
def some_form(request, data: SomeSchema = Form(...)):
...
This syntax looks cleaner/short and has the same code completion hints in popular editors.
On the other hand the old syntax is still supported so you can easy port your project to a newer django-ninja version
Bug changes and improvements
- Forbid extra by @nofalx in #863
- Add a test for list query params by @marius-mather in #852
- (docs) Fix typo in path-params.md by @dipbazz in #854
- (docs) Fix note to be admonitions in query-params.md by @dipbazz in #855
What's new in 1.x
- async authentication fully supported on all layers
- CSRF is now automatic on Cookie based authentication ( now you should be able to combine multiple cookie/header/etc authenticators and play around with csrf logic)
- Pydantic2 - which has a core re-written in Rust and includes a lot of improvements and features like:
- Safer types.
- Better extensibility.
- Better performance - so far on few projects that I tested getting average 10% speed improvements (some particular views which do lot of validations should get pretty good bumps)
- schema validators/resolvers now have extra context (like request)
- Pagination class accepts a request object
- Support for
Annotated[]
syntax - allow adding routers by string path instead of explicit import
Unfortunately Django ninja integrates very deep into pydantic core with Schema class, so it is not possible to keep both pydantic v1 and v2 supported - and that is why ninja now bumps to version 1 which might have few deprecations or breaking changes on pydantic level
From Django ninja side I'm trying to make this upgrade as smooth as possible, if you use standard APIs without lot of magic - most likely upgrade should be without any code change
New Contributors
- @marius-mather made their first contribution in #852
- @dipbazz made their first contribution in #854
- @nofalx made their first contribution in #863
Full Changelog: v1.0b1...v1.0b2
1.0 beta1
Warning: This is a pre-release of Django Ninja V1
On the other hand this is a beta release, so no more dramatic changes expected - mostly bug fixes
There is only one major syntax thing that I'm still considering to add to 1.0 - shorter annotations - #746 - Please take a look and give your vote/thoughts
What's new
- async authentication fully supported on all layers
- CSRF is now automatic on Cookie based authentication ( now you should be able to combine multiple cookie/header/etc authenticators and play around with csrf logic)
- Pydantic2 - which has a core re-written in Rust and includes a lot of improvements and features like:
- Safer types.
- Better extensibility.
- Better performance - so far on few projects that I tested getting average 10% speed improvements (some particular views which do lot of validations should get pretty good bumps)
- schema validators/resolvers now have extra context (like request)
- Pagination class accepts a request object
- Support for
Annotated[]
syntax - allow adding routers by string path instead of explicit import
Unfortunately Django ninja integrates very deep into pydantic core with Schema class, so it is not possible to keep both pydantic v1 and v2 supported - and that is why ninja now bumps to version 1 which might have few deprecations or breaking changes on pydantic level
From Django ninja side I'm trying to make this upgrade as smooth as possible, if you use standard APIs without lot of magic - most likely upgrade should be without any code change