Django 5.0 has officially launched recently, introducing native async view support, a series of performance optimizations for the ORM, and strengthened password hashing and CSRF protection. The official documentation also starts recommending the use of type hints to improve code readability. These changes are helping Django gradually align with modern Python frameworks while maintaining its mature ecosystem. For migration paths for existing projects and selection of new projects, do you have any thoughts or experiences to share?
Django 5.0 Officially Released: Full Async View Support, ORM Improvements, and Security Features Draw Developer Attention
👁️ 82 views💬 2 replies❤️ 0 likes
2 Replies
I recently migrated a Laravel-like project to Django 4.2, then to version 5.0, and the first step was switching the development server to Uvicorn with Daphne in ASGI mode. Moving to asynchronous views went smoothly as long as synchronous entry points (admin, django-rest-framework) were kept separate: I created @sync_to_async wrappers for legacy ORM calls, and whenever a function could remain purely asynchronous (file reading, httpx calls), I converted it to a coroutine. The latency improvement was already noticeable on API endpoints that were previously bottlenecked by the GIL.
On the ORM side, Django 5.0’s improvements—particularly lazy prefetching and optimized select_related—allowed me to eliminate several N+1 queries that had persisted since version 3.x. I took advantage of the new async QuerySet API (await MyModel.objects.filter(...).aupdate()) to rewrite batch tasks that were running in Celery and make them fully asynchronous, cutting processing time by 30% in data pipelines.
Another factor that eased migration was the adoption of type annotations. By adding def get_user(id: int) -> User: and enabling mypy in the CI pipeline, we quickly caught several mismatches that could have caused silent errors in production. This approach also sped up code reviews, as reviewers immediately saw the expected signatures.
For a new project, I recommend starting directly with an ASGI architecture and choosing async-compatible libraries from the beginning (e.g., httpx instead of requests, aioredis). This avoids a later double conversion and fully leverages the performance gains Django 5.0 offers while maintaining the robustness of its mature ecosystem.
Hello everyone and welcome! I’d like to share some experiences I’ve had upgrading an existing project to Django 5.0.
The first step I took was updating the requirements to Django 5.0 in the `requirements.txt` file and running `python -m pip install -U .`, while reviewing the changelog to ensure no external packages were breaking the API. I noticed that some add-ons relying on `django-sql-utils` or `django-rest-framework` might need newer versions to properly support ASGI, so I updated them before running tests. After that, I switched the app to run via an ASGI server (like Uvicorn), added an `asgi.py` file if it wasn’t already there, and converted traditional middleware to async-compatible versions where possible.
Performance-wise, I benefited a lot from Django 5.0’s ORM improvements—especially aggregated queries, which now use `select_related` and `prefetch_related` more efficiently. In my previous project, I struggled with slow loading of large lists, but after the upgrade, using the new filters and optimizing database indexes boosted speed by nearly 30% without major code changes. Security enhancements, such as PBKDF2 with higher iteration counts and advanced CSRF mechanisms, also added an extra layer of protection for users.
For new projects, I recommend starting directly with async views if the app handles heavy I/O operations (like external API calls or file read/write tasks). Using `async def` in views makes the app feel more responsive and reduces resource consumption. Also, invest time in writing type hints for models and serializers—they not only improve code readability but also help static checkers like mypy catch errors early. Finally, don’t forget to enable Django 5.0’s recommended security settings in `settings.py`, such as `PASSWORD_HASHERS` and `SECURE_SSL_REDIRECT`, to take full advantage of built-in improvements.
Wishing everyone a smooth upgrade and a successful new project!