Life is short, use Python (and Django)

archiemeng | created on Feb. 3, 2020, 1:56 p.m.

Updated on March 18, 2021, 2:13 p.m. | viewed: 355

In my last semester, I took a unit called Web Application which uses ASP.NET MVC framework. It was devastated since I messed up all the things about it. I had terrible data logic design, buggy database processing and ugly surface for my unit project. I was frustrated with doubts about my ability til now when I decided and successfully made this blog application. Yes, I was wrong. My web development skill is not that bad. My poor score in that unit is just the result of the bullshit ASP.NET framework (Yes, I just got 59 for that unit). In this article, I will explain how I built this application from scratch and the most apparent differences between ASP.NET and Django in my own opinions.


First of all, I do recommend the "writing your first Django app" tutorial. It's written by the Django official, easy to understand and detailed in explanations of how the sample codes work. Impatient people like me who quickly developed this website in just three days can read only the first four parts of the tutorial for they briefly explained things from how to set up a Django project as well as how to make this project personal by customizing models and views.


When I was developing my application from scratch, I found that Django is smoother and more developer-friendly than ASP.NET. One example is that I had experienced countless remake of the .NET projects for data models changes. Because every time I change the model, the whole project won't work and crash. I tried to search for solutions on the Internet but found that only a few results were related and unhelpful. Then I asked for help from teachers and classmates, and they just told me that remaking it would work and never change models during development. Fuck's sakes! In Django, as long as your models are correct, the only things to do are just


$ python makemigrations
$ python migrate


Even if the model has some inappropriate settings like adding new fields to an existing model without default settings, Django will help you fix these.



Another thing that sucks on ASP.NET but pretty good on Django is the project configurations. ASP.NET is so huge that I cannot find all the configuration files. And when I was working on these project in Visual Studio, I didn't know where to configure the database to connect and always forgot which database server I was currently connecting to. One of my classmates said to me that ASP.NET is tremendous and large that only excellent programmers can handle it very well, and we were not good enough. I now find it a total joke. In Django, the corresponding database configuration is clearly written in the of the project. And you don't need to be panic when the connection is wrong, traceback to even Django source code is supported while in ASP.NET, you will never know what those error messages mean in your life. When there is a clear, simple way and another complicated, difficult way which programmers will always make some mistakes, which one do people want? The answer is obvious. So I feel so happy about working with Django.


Now that, I only want to say "ASP.NET, shame on you!".


After finishing my reading of the tutorial on the second day of development, I decided to find a blog template to use. Unlike ASP.NET MVC framework, which provides usable initialized views at the time of project creation, Django is a straightforward framework in which developers have to write views on their own. But this little convenience cannot change my critical opinion to ASP.NET for finding and customizing existing templates is not that hard. I found a template very soon from building-a-blog-application-with-django. This article contains sample view codes and some links to other useful blog extension tutorials as well.


During the customization of the templates, I added several features to it. One is making the existing sidebar floating with user scroll. I didn't search for its implementation directly. I borrowed the idea of how to set widgets position from the implementation of "back to top button". When users scroll the page, the JavaScript scripts will automatically compute and set the appropriate location for the sidebar. And for the sidebar to stay on the page, "position: fixed" is set for its style. But on the mobile screen, the position fixed sidebar is overlayed by article lists. In this case, I programmed to restore its default appearance when being viewed on a narrow screen.


In the future, I will definitely add more functions to this my first Django project. Such as the comment system and third party login system. Please be looking forward to my incoming updates! At last, let me repeat that saying again. "Life is short, use Python."