In the realm of web development, the longevity and relevancy of technology are subjects of constant debate. Among the venerable yet often scrutinized technologies is Django, the Python-based web framework known for its “batteries included” philosophy. As of 2024, the question of whether Django remains a viable choice for modern web applications is more pertinent than ever. This article aims to dissect various perspectives, including critique, market data, and the framework’s evolution to provide a balanced view.
Podcast highlight
The state of Django
Despite the rise of new technologies and frameworks, Django has maintained a substantial user base and market share. As of my last knowledge, Django boasted around 42,094 current customers, securing a 32.80% market share amongst web frameworks, positioning it as the market leader ahead of its competitors like Ruby on Rails and the Spring Framework. This data alone challenges the notion of Django’s decline, instead suggesting a robust and sustained usage.
Critiques and challenges
However, no technology is without its critics. In an insightful piece by David Dahan from October 2021 titled “The decline of Django” several points of contention were raised. Key critiques included a perceived stagnation since Django 2.0, outdated tooling, and documentation, the slow integration of modern web development practices such as asynchronous support, and a lack of support for static typing. Dahan also lamented Django’s traditional MVC (Model-View-Controller) architecture as potentially being out of step with the rise of Single Page Applications (SPAs) and backend-only services.
These criticisms, while not to be dismissed lightly, present a snapshot in time. The technology landscape is fluid, and open-source projects like Django evolve in response to both community input and the changing demands of web development.
Modernizing efforts and asynchronous support
In recent years, Django has taken significant steps to modernize and address some of the critiques levied against it. One of the most anticipated changes has been the push to integrate comprehensive asynchronous support. Beginning with Django 3.1, asynchronous views, middleware, and test clients have been gradually introduced, showing a commitment to evolving the framework in line with modern development practices.
Additionally, Django 5’s ongoing initiative to enhance async functionality indicates a recognition of past shortcomings and a determination to future-proof the framework. Such initiatives are crucial for Django’s sustainability and relevance, particularly in an era where non-blocking I/O operations and real-time data handling become increasingly important for web applications.
Mariusz Felisiak, a recognized contributor to both Django and Python, sheds light on how recent async improvements bring a plethora of possibilities to Django developers. Starting from Django 3.0, with the inclusion of ASGI (Asynchronous Server Gateway Interface) support, Django has embarked on a path that has methodically built towards a comprehensive asynchronous request-response cycle. This journey saw notable landmarks with each subsequent version:
- Django 3.1 introduced asynchronous views and middleware, making it possible to define non-blocking web request handlers.
- Django 4.0 added asynchronous API for cache backends, broadening the scope of async capabilities in Django.
- Django 4.1 welcomed the asynchronous Object-Relational Mapping (ORM) interface, a considerable stride towards database operations that don’t block the server’s responsiveness.
- Moving forward to Django 4.2, features like asynchronous streaming responses and support for psycopg3 showcased an increasing commitment to fully asynchronous workflows. psycopg3’s support, notably, paves the way for asynchronous database connections and cursors, illustrating Django’s dedication to database interaction efficiency.
- The currently under development Django 5.0 ambitiously aims to integrate asynchronous signal dispatch and coroutine handling for user authentication, among other features. This reflects an aspiration to make asynchronous programming pervasive throughout Django.
Felisiak’s exploration puts a spotlight on the practical application of these advancements. An exciting example is the potential to run multiple async tasks concurrently within a Django view—imagine fetching user data and processing database queries simultaneously without letting one task block another. This not only improves the efficiency of web applications but also aligns with the real-time demands of today’s user experiences.
Addressing the nuances of writing async views, Django simplifies the transition for developers with familiar patterns. An async def
marks a view as asynchronous, after which, Django’s intelligent handling ensures it runs within an async context. The ability to seamlessly mix synchronous and asynchronous code with tools like asgiref.sync.sync_to_async()
further demonstrates Django’s flexible approach towards modern web development challenges.
Moreover, with the adoption of asynchronous database operations via psycopg3 and async interfaces for common tasks like ORM queries and external API calls, Django shows it’s not just dipping its toes but diving deep into the async pool. This leap is bound by practicality and caution, as seen in the stepwise integration of async features, ensuring stability and backward compatibility.
The role of community and documentation
As for documentation and community support, it’s essential to recognize that Django’s comprehensive documentation has been a double-edged sword. While it can seem overwhelming to newcomers, it also signifies Django’s commitment to transparency and supplying developers with the resources they need. The community around Django has also been proactive in maintaining relevance through third-party packages, forums, and contributions, further enriching the framework’s ecosystem.
My personal perspective
From my viewpoint, Django is far from dead. It continues to be my go-to choice for web applications, largely due to its quality, security features, optimization possibilities, and robust ORM. The gradual integration of asynchronous programming is a significant step forward, addressing one of the most pointed criticisms of the framework. Moreover, the very active and vibrant community that surrounds Django adds a layer of dynamism and innovation, which is often overlooked when discussing the framework’s vitality.
In regards of Django Rest Framework (DRF), I am approaching this problem like this:
- if I need to build purely an API project -> FastAPI;
- if I need a complete web app -> Django;
- if I need long-running tasks -> Django + Celery;
Conclusion
In summary, while Django has faced criticism for certain aspects of its approach and feature set, it remains a formidable and popular choice in the web development ecosystem. Its leading market share, active community, and ongoing modernization efforts refute the notion that it is becoming obsolete. Like any mature technology, Django must balance its rich heritage with the need to evolve, a challenge it has met with thoughtful iterations and a forward-looking roadmap. Thus, declaring Django “dead” would be not only premature but also a gross underestimation of its resilience and adaptability in the ever-evolving landscape of web development.