First Impressions on Django

What is Django?

Django is a web framework that first appeared on 2005 to build full stack web applications using Python.

I have been using it for the last few weeks in my end to end projects for building Eventor, which attempts to be an event management software for organizations that will leverage currently available AI technologies.

This article will be a commentary of my first impressions on it and probably help anyone that might be interested to invest time adding it to their toolbox.

The reasons to use it

Django implements something called the Model-Template-View architecture where:

The official reasons for using Django is that it provides a “ready to go” framework to handle most of the pain points present in web development.

For me the main attraction of using Django was that it was a full stack framework in which I could package my own end to end projects in a neat and well-designed application I could show to the world.

The real reasons its is being used

Most people I know that have used Django in the wild have reasons for using Django that usually touch the following points.

They already know Python because they come from a science background and are not interested in learning more about how computers work, they just want to build a dynamic website to achieve some kind of objective.

They want to avoid using a JavaScript framework or JavaScript altogether, which is understandable given the lack of high quality reusable components that are out there on the web for front-end development.

They might do not know how to work with SQL and want to use an ORM instead. Those who fall in this category are in for a rude awakening once their application needs to scale.

However, I am of the opinion that having scalability problems on an application that has a viable business model is a really nice problem to have.

Let’s be real here, if you have performance issues with your basic CRUD application, it is probably not the ORM and you should learn how to use a profiler, for which Django gives a sugestion.

Finally, another kind of recurrent user are those that need to interact with a database using forms and are scared of SQL injections, me and many developers would personally fall within this realm due to the heavy weight that cybersecurity awareness has over us.

This is partially solved by a great deal of integrated form validators that you can import into your project and a stable permissions and authentication framework for managing your users and their profiles.

This framework also provides a great deal of solved solutions for hard problems such as search, which is something that every large content management system will eventually face.

Django also provides a large set of guides to do things well, which is appreciated by developers that did not begin their careers as senior web developers with 20 years of experience and are willing to learn the complexities of building for the web. Good and updated documentation goes a long way for projects such as these, and this is indeed one of the strength for this framework.

For putting things into perspective, when I learned React I had to waste a lot of time just finding a way to start a project with modern JavaScript that would not yield npm warnings each time I executed it because the version of ECMAScript of the default dependencies of my project were depreciated.

In the end I achieved this with Vite BTW, I had to solve this basic problem by adding a third party dependency. Welcome to JavaScript land, where everyone use and profit from it, but few take care of it, a tragedy of the commons of the modern time.

Some issues I found

Django is not perfect and as with anything in science and engineering, you seldom solve lack of skill, experience or plain stupidity with a single tool or framework.

One of the issues I have been dealing with is that if I want to add a CSS framework such as Bootstrap, I cannot simply use the automatic HTML rendering of forms. This usually means I need to code them myself on the templates, which takes away some of the advantage of reduced coupling between the templates the views and the models of a site.

Another issue that this framework has is that integrations with a stateful front end component is somewhat complex, but there are multiple solutions over the net on how to achieve this.

Django comes from the remote past of the 2000s a world dominated by the idea that web applications needed multiple pages, while most modern reactive applications today only consider a single page.

One solution is simply to encapsulate reactive applications as individual pages in this multipage paradigm.

Another solution is to conceive Django only as a REST framework that use it through a variety of clients using these reactive frameworks or other kind of native applications. This is probably the best way to use Django in the 2020s in order to guarantee the highest decoupling from the front-end logic, which might come with the sacrifice of some full-stack features.

On a more personal note, I am having issues regarding how to test the code I produce in this framework. I have been following the doctrine of solving the problem first then doing the tests later to cement the right functionality of my code via a battery of unit tests and a refactor after which I then keep progressing.

However, testing web flows is not a trivial task. It requires mocking user sessions, requests, responses and establishing a concrete state in the database, it is not yet clear for me how to make this effectively and will need to research further on how to do this correctly.

This also means that I might need to throw most of the code away for this project, which is a necessary part of learning a new tool.

I also feel like I have been wasting a lot of time centering <div>’s on the website, which is somewhat frustrating, given that on top of all the technical complexity of the site I also need to deal with aesthetics.

This could be in practice easily solved by partnering with a designer or a front-end developer. For small prototypes where functionality has priority over form, this problem is meaningless.

However, the issue with design is massive when looking for product market fit and I will need to explore it further in the future.

The outcome

Building this project with Django has provided me with a better understanding of how to build reliable web applications.

Amusedly, it has also provided me with an appreciation for languages such as PHP, specially when paired with a framework such as Laravel, and am seriusly considering investing time in getting proficient at it for integrating backends with applications such as WordPress or NextCloud which implement their respective APIs on this technology.

This is a very interesting suggestion because most small clients that want customizations for their systems are usually looking for plugins instead of full websites.

I will keep developing Eventor until it is able to achieve its main purpose of facilitating the management of events in the MakeSpace I am participating in, which will surely require these kinds of integrations.

I will keep you posted, keep building.

whoami

Jaime Romero is a software developer and cybersecurity expert operating in Western Europe.