Skip to content

Releases: vitalik/django-ninja

1.0 alpha1

12 Jul 15:26
e4c10ad
Compare
Choose a tag to compare
1.0 alpha1 Pre-release
Pre-release

Warning: This is a pre-release of Django Ninja V1

You probably should not use this version in production


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)

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

0.22.2

08 Jun 15:42
Compare
Choose a tag to compare
  • Fixed schema generation bug #774

0.22.1

28 May 07:16
Compare
Choose a tag to compare

Fixes a swagger ui error

0.22.0

27 May 18:42
9c6f136
Compare
Choose a tag to compare

What's Changed

  • ModelSchema now support config.model_fields_optional to mark some or specific fields to be not required in schema
  • Implement rudimentary support for async auth by @kjagiello in #735
  • Allow to extend additional info key, value to OpenAPI Info section by @chenatlas in #715
  • fix typo by @quique in #706
  • api_operation is better described as a decorator by @quique in #707
  • Added a section detailing how to reverse a url for the api docs page. by @SunsetOrange in #714
  • Fix missing openapi endpoints by @rednaks in #731
  • Add Django 4.2 support in pyproject.toml by @baseplate-admin in #736
  • Added missing space by @TheHippo in #737
  • fix: allow default example to be included in pagination output in generated API docs. by @jkeyes in #728
  • Fix kwargs typing by @SmileyChris in #745
  • Only title-case fields in schema if all lowercase verbose name by @SmileyChris in #748
  • fix: paginate typo by @MrEcho92 in #752
  • feat: add JSON encoding support for IPv4Address and IPv6Address by @jkeyes in #729
  • Enable exception_handler to handle Pyright's strict mode by @paulzakin in #762
  • Make optional field of UploadedFile optional by @karlosss in #766

New Contributors

Full Changelog: v.0.21.0...v0.22.0

0.21.0

24 Feb 14:16
41e9bbf
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.20.0...v.0.21.0

0.20.0

17 Dec 15:27
432ab53
Compare
Choose a tag to compare

What's Changed

Documentation

Misc

New Contributors

Full Changelog: v0.19.1...v0.20.0

0.19.1

20 Jul 15:41
97a83b8
Compare
Choose a tag to compare

What's Changed

  • Declare the AuthenticationError exception class in all by @duducp in #489
  • Small fix for many2many payloads to allow passing primary keys for model fields

Documentation

New Contributors

Full Changelog: v.0.19.0...v0.19.1

0.19.0

29 Jun 08:46
7b134f3
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v.0.18.0...v.0.19.0

0.18.0

03 Jun 09:01
4e3a838
Compare
Choose a tag to compare

Hello

Please welcome the new Django Ninja version
it has lot of fixes and improvements

Most notable a HttpResponse typed argument by @SmileyChris

Now you can manage response behaviour (cookies, headers, streaming) flixible:

@api.post("/boop")
def boop(request, response: HttpResponse): # !
    response.set_cookie("beep", "boop") # !
    return True

All changes

New Contributors

Full Changelog: v0.17.0...v0.18.0

0.17.0

03 Feb 22:03
Compare
Choose a tag to compare

This release brings few long awaited features:

Smarter schema

Now you can access orm instance attributes inside schema with resolvers:

class TaskSchema(Schema):
    title: str
    is_completed: bool
    owner: Optional[str]
    lower_title: str

    @staticmethod
    def resolve_owner(obj):  # <------- !!!!!!
        if not obj.owner:
            return
        return f"{obj.owner.first_name} {obj.owner.last_name}"

    def resolve_lower_title(self, obj):   # <-------- !!!!!!
        return self.title.lower()

Field aliases now support django template variables dotted syntax:

class TaskSchema(Schema):
    ...
    last_comment: str = Field(..., alias="comment_set.0.text")

Thanks to @SmileyChris

Pagination output

Now default paginated output returns a dict with items and count

You can now override both input and output schemas for custom pagination:

class CustomPagination(PaginationBase):

    class Input(Schema):
        page: int
        
    class Output(Schema):
        items: List[Any]
        total_pages: int
        current_page: int
    
    def paginate_queryset(self, queryset, pagination: Input, **params):
        return {
            'items': ...,
            'total_pages': ...,
            'current_page': ...,
        }

All updates:

New Contributors

Full Changelog: v0.16.2...v0.17.0