Skip to content

Releases: vitalik/django-ninja

1.3.0

15 Aug 09:14
b1ecd36
Compare
Choose a tag to compare

This version brings few enahcments

  1. 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)
  1. 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

New Contributors

Full Changelog: v1.2.2...v1.3.0

1.2.2

16 Jul 13:49
bcf7014
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.2.1...v1.2.2

v1.2.1

05 Jul 15:55
4de0af9
Compare
Choose a tag to compare

Fixed throttling in async mode

1.2.0

27 Jun 13:40
49e8b80
Compare
Choose a tag to compare

What's new

with most notable

All changes:

Docs

New Contributors

Full Changelog: v1.1.0...v1.2.0

1.1.0

07 Dec 22:13
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.0.1...v1.1.0

1.0.1

17 Nov 10:15
Compare
Choose a tag to compare

Fixed from_orm compatibility

1.0

16 Nov 16:59
7f6b322
Compare
Choose a tag to compare
1.0

Read more details and examples here https://django-ninja.dev/whatsnew_v1/

or watch overview video :

SCR-20231116-qmoj

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

07 Nov 16:59
cd66ac8
Compare
Choose a tag to compare
1.0 RC Pre-release
Pre-release

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

Full Changelog: v1.0b2...v1.0rc

1.0 beta2

01 Oct 17:55
Compare
Choose a tag to compare
1.0 beta2 Pre-release
Pre-release

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


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

Full Changelog: v1.0b1...v1.0b2

1.0 beta1

10 Sep 15:40
Compare
Choose a tag to compare
1.0 beta1 Pre-release
Pre-release

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

Many thanks to contributors