Migration
Migrate to 3.0¶
Most version 2 code runs on 3.0 unchanged and shows a DeprecationWarning
where something should be renamed. Follow these steps to upgrade.
Upgrade the package¶
Bash
pip install --upgrade "django-ninja-aio-crud>=3,<4"
Version 3 supports Python 3.10 to 3.14 and Django Ninja 1.7.x.
Check the breaking changes¶
Read breaking changes. The most common ones are:
async defhooks need theaprefix, likeapost_create.Serializer.create(),update()andmodel_dump()are sync; useacreate(),aupdate()andamodel_dump()in async code.PATCHonly changes the fields the client sends.
Run the checks and the tests¶
Bash
python manage.py check
python -W error::DeprecationWarning manage.py test
check validates every Schemas class. Turning warnings into errors shows each
place that uses a deprecated name.
Replace deprecated code¶
Use the deprecations table and the recipes
to move to the version 3 names, for example inner serializer classes to
Schemas, and ModelUtil calls to Article.create() and
Article.amodel_dump().
Try the sync mode (optional)¶
If your project runs on WSGI, you can now serve viewsets with sync views:
Python
@api.viewset(model=Article)
class ArticleViewSet(APIViewSet):
execution_mode = "sync"
See sync and async.
Checklist¶
- Package upgraded and
python manage.py checkpasses - Async hooks renamed with the
aprefix - Awaited
Serializermethods changed toacreate(),aupdate(),amodel_dump() - Tests pass with
-W error::DeprecationWarning - Clients reviewed for the new
401,409andPATCHbehavior