Skip to content

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 26, 2025

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
django-ninja (source) ~= 1.3.0 -> ~=1.4.0 age adoption passing confidence

Release Notes

vitalik/django-ninja (django-ninja)

v1.4.0

Compare Source

What's new

File uploads

request.FILES in non-POST request - basically there is a long story where Django does not set request.FILES for methods like PUT, PATCH
Users were just struggling to understand why their API endpoints are not validating and had to add special middleware that fixes that
Now django ninja will automatically notify user in that case and will ask to add that middleware when user uses non-POST methods

Pagination

  • Inproved performance for async views with pagination
  • PageNumberPagination support page_size (DRF similarity)

Validation errors

Requests that fail validation raise ninja.errors.ValidationError (not to be confused with pydantic.ValidationError).
ValidationErrors have a default exception handler that returns a 422 (Unprocessable Content) JSON response of the form:

{
    "detail": [ ... ]
}

Error context
Now you can customise it by overwriting the following method:

class CustomNinjaAPI(NinjaAPI):
    def validation_error_from_error_contexts(self, error_contexts): ...

pattern= Support

Regex pattern fully compatible with latest pydantic, allows you to add extra validation in arguments:

@​router.get("/path/param-pattern/{item_id}")
def get_path_param_pattern(request, item_id: str = Path(..., pattern="^foo")):
    return item_id

Custom Django model fields

there is now a standard way to register custom django field to pydantic type:

from ninja.orm import register_field
register_field("MyCustomField", int)

Throttling

Throttling now supports multi-period intervals, such as 5/30s, 10/5m, and 100/2h. Previously, the throttling implementation only allowed single-period intervals (e.g., 5/s, 100/d), which limited the granularity and flexibility of rate limits.

Full Changelog

Tests
Docs

New Contributors

Full Changelog: vitalik/django-ninja@v1.3.0...v1.4.0b1


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot force-pushed the renovate/django-ninja-1.x branch from 73b82c8 to 5f23b3d Compare March 31, 2025 19:52
@renovate renovate bot force-pushed the renovate/django-ninja-1.x branch from 5f23b3d to 102aa27 Compare March 31, 2025 19:53
@julienc91 julienc91 merged commit 66b4a16 into main Mar 31, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant