Why Django

api
web
frontend
software-architecture

Web frameworks are designed to support building a web frontend as well as the API layer. Django is a popular and widely used framework.

Author

Richard Ding

Published

March 22, 2023

Modified

February 26, 2024

Introduction

We have evaluated several web frameworks for the Seedcase Product, and have chosen Django as the most suitable option for the web framework. This document describes the reasoning behind this decision and outlines the key factors that influenced it.

Decision

After evaluating Flask, Ruby on Rails, FastAPI, and Django, we have decided to use Django as the web framework for Seedcase.

All considered web frameworks use Python. For our decision to use Python, see the page Why Python.

Alternatives Considered

Flask

Flask is a lightweight web framework that is easy to use and has a low learning curve. It provides a lot of flexibility and does not enforce any particular project structure. Flask has a small footprint and is a good option for simple web applications or prototypes.

However, Flask does not provide some of the advanced features that Django has, such as an admin interface, an object-relational mapper (ORM), and a built-in authentication system. These features would need to be implemented manually or by using third-party libraries.

Ruby on Rails

Ruby on Rails is a popular web framework that provides a lot of built-in features and conventions. It has a large and active community and provides good support for agile development practices. Ruby on Rails is a good option for rapid application development and has good support for testing.

However, Ruby on Rails requires developers to have experience with the Ruby programming language, which may not be ideal for all teams and isn’t a common language in scientific environments. Additionally, Ruby on Rails has a large footprint and can be slow for certain use cases.

FastAPI

FastAPI is a modern, high-performance web framework for building APIs with Python. It is designed to be fast, and easy to use. FastAPI includes features like automatic validation of request bodies, async support, and built-in OpenAPI documentation. These features make it a popular choice for building scalable and maintainable APIs, especially for applications that require high performance real-time responses.

However, it’s important to consider the specific needs of the Seedcase Product. FastAPI may be a good choice for applications that require high performance real-time responses, but not as good a choice for more complex web applications that require a full-stack framework with many built-in features. It is also newer, so it is still maturing and has a small, though active, community, which limits the amount of available support and resources.

Factors that influenced the decision

Several factors influenced our decision to use Django over Flask, FastAPI, and Ruby on Rails as the web framework:

API Development

Django provides excellent support for API development through its built-in serialization framework and REST framework. The REST framework provides a lot of functionality out of the box, such as authentication, pagination, and filtering. Additionally, Django provides good support for other types of APIs, such as GraphQL.

Data Management

Django provides a powerful ORM that abstracts away much of the database logic and allows developers to work with database models in a Pythonic way. It provides good support for migrations, which makes it easy to evolve the database schema over time. Django also provides a built-in admin interface that allows non-technical users to manage data.

Security

Django provides good support for security through its built-in authentication system and its support for common security practices such as Cross-Site Request Forgery (CSRF) protection and password hashing. It also provides good support for role-based access control and fine-grained permissions.

User Management

Django provides good support for user management through its built-in authentication system and its support for user profiles and social authentication. It also provides good support for password resets and account activation.

Conclusion

After evaluating Flask, FastAPI, Ruby on Rails, and Django, we have made the decision that Django is the better fit for Seedcase. Django has the benefits of a built-in serialization framework and REST framework for API development, providing a powerful ORM and good built-in support for security, as well as user management.