Django-ninja-aio-crud

Latest version: v0.7.8

Safety actively analyzes 723158 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 4

0.2.1

What's Changed

News:
* NinjaAIO class implementation by caspel26.

**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/compare/v0.2.0...v0.2.1

🥷 NinjaAIO class
* NinjaAIO class inherits from **<a href="https://django-ninja.dev/reference/api/">Django Ninja NinjaAPI</a>** but it uses built-in parser and renderer which use orjson for data serialization. This class is necessary to make able serialization works.

Python
from ninja_aio import NinjaAIO
from ninja_aio.views import APIViewSet

from test.models import Foo

api = NinjaAIO()

class FooAPI(APIViewSet):
model = Foo
api = api

FooAPI().add_views_to_route()

0.2.0

What's Changed

News:
* Many to many relation serialization support by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/7

Bugs:
* Bugfix: router path name in model CRUD router by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/7
* Bugfix: OneToOne reverse and forward relations by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/7

Improvements:
* Improved models serializeration by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/7

🎉 ManyToMany schemas serialization support
* many to many support is finally here. you can define your models and insert the many to many field in reverse and forward relations in ReadSerializerClass.

Python
models.py
from django.db import models
from .ninja_aio.models import ModelSerializer

class Bar(ModelSerializer):
name = models.CharField(max_length=30)
description = models.TextField(max_length=30)

class ReadSerializer:
fields = ["id", "name", "description", "foos"]

class CreateSerializer:
fields = ["name", "description"]

class UpdateSerializer:
fields = ["name", "description"]


class Foo(ModelSerializer):
name = models.CharField(max_length=30)
active = models.BooleanField(default=False)
bars = models.ManyToManyField(Bar, related_name="foos")

class ReadSerializer:
fields = ["id", "name", "active", "bars"]

class CreateSerializer:
fields = ["name", "active"]

class UpdateSerializer:
fields = ["name", "active"]


* Then add APIViewSets.

Python
views.py
from ninja import NinjaAPI
from .ninja_aio.views import APIViewSet
from .ninja_aio.parsers import ORJSONParser
from .ninja_aio.renders import ORJSONRenderer

from . import models

api = NinjaAPI(parser=ORJSONParser(), renderer=ORJSONRenderer())


class FooAPI(APIViewSet):
model = models.Foo
api = api


class BarAPI(APIViewSet):
model = models.Bar
api = api


FooAPI().add_views_to_route()
BarAPI().add_views_to_route()

* And that's it! Django Ninja Aio Crud will create dinamically all the schemas that you need and resolve all the relations! If you want to add a view to add, for example, a "bar" or multiple "bars" instances to Foo it could be something like that.

Python
views.py
from ninja import Schema
from ninja_aio.schemas import GenericMessageSchema


class AddBarsSchema(Schema):
bars: list[int]


class FooAPI(APIViewSet):
model = models.Foo
api = api

def views(self):
self.router.patch(
"{id}/add-bars/", response={200: self.schema_out, 404: GenericMessageSchema}
)
async def add_bars(request: HttpRequest, id: int, data: AddBarsSchema):
try:
foo = await models.Foo.objects.prefetch_related("bars").aget(pk=id)
except models.Foo.DoesNotExist:
return 404, {"foo": "not found"}
for bar_id in data.bars:
try:
bar_obj = await models.Bar.objects.aget(pk=bar_id)
except models.Bar.DoesNotExist:
return404, {"bar": "not found"}
await foo.bars.aadd(bar_obj)
await foo.asave()
foo = await models.Foo.objects.prefetch_related("bars").aget(pk=id)
return 200, foo


**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/compare/v0.1.4...v0.2.0

0.1.4

What's Changed
* Fix render model list view with pagination and improved relations serialization by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/6


**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/compare/v0.1.3...v0.1.4

0.1.3

**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/compare/v0.1.2...v0.1.3

What's Changed
* Async Pagination now supported and it can be customized. Check README for more information. implementation by caspel26

0.1.2

**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/compare/v0.1.1...v0.1.2

0.1.1

What's Changed
* Update README.md by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/1
* Update README.md by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/2
* Update README.md by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/3
* Custom fields implementation by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/4
* Update README.md by caspel26 in https://github.com/caspel26/django-ninja-aio-crud/pull/5

New Contributors
* caspel26 made their first contribution in https://github.com/caspel26/django-ninja-aio-crud/pull/1

**Full Changelog**: https://github.com/caspel26/django-ninja-aio-crud/commits/v0.1.1

Page 4 of 4

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.