Skip to content

Releases: vitalik/django-ninja

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

0.16.2

20 Jan 14:15
37f6da9
Compare
Choose a tag to compare

Many documentaion fixes and improvements by:

0.16.1

12 Oct 09:21
170fc58
Compare
Choose a tag to compare

0.16.0

06 Oct 15:42
dc304cc
Compare
Choose a tag to compare

OpenAPI schemas names

Generating OpenAPI automatically created schema names changed for duplicated names (see #230)
Now instead of silence (or exceptions on other cases) django-ninja will just add sequential number suffix to the schema name in OpenAPI spec.
For example if you already have schema called "User" and in some other module you create another "User" schema - the second will have name "User2" in openapi json.

Other

0.15.0

18 Sep 13:54
26478c7
Compare
Choose a tag to compare

Major changes

Other changes

0.14.0

14 Aug 12:40
Compare
Choose a tag to compare

Hello Everyone,

This is a very nice release, which includes some new functionality and fixes
And more important there are lot of people contributed to this update
Thank you

0.13.2

05 Jun 15:54
be96905
Compare
Choose a tag to compare

TestClient csrf check fix

0.13.1

03 Jun 09:29
56ad4d6
Compare
Choose a tag to compare

fixed schema generation bug (#145)

0.13.0

18 May 13:18
642d762
Compare
Choose a tag to compare
  • Fixed create_schema ValueError on pydantic 1.8.2 (#135)
  • Allow collection fields to be identified when an alias is used #133 (by @kierandarcy )
  • New argument custom_fields in create_schema to override or add fields
  • Fixed create_schema Json field (#127)
  • Include ninja TestClient into distributed package