Revisiting Django and Flask

A little over two and a half years ago, I decided to dabble in the world of Python web-apps by following the book "Django By Example". Having done Python courses before, I knew my basic way around the language but I had never put together a proper application in any way, shape or form. 

Starting Django from the book was a leap for me. I had heard of Django before, I knew it was a framework that let you make web-apps, but I had no idea how any of it worked. My lack of experience with proper Python apps didn't help my position either. For a large chunk of the project, I was just following the book and not quite understanding what was happening.

I'd go "Yayy!" every time my code worked but I did not fully grasp what was happening or how it actually worked. 

This meant that when I ran into issues, I was completely and utterly stuck. Because I did not actually understand what the line of code that I was typing was actually doing. An important thing to add: I am a visual learner by a long shot. I learn better if I'm actually watching something being implemented, as opposed to reading about it. That was one of the reasons why I struggled. 

The biggest reason though: this was 2018 and I was using Django version 1. Which if you've used Django for a period of time, you'll know that it was needlessly more complicated than needed. One major example was about how the "urls.py" file was heavy on regular expressions, regex for short. Regex is one thing I've always struggled to comprehend, even before I started working with Django. 

Despite all of that, I managed to complete two of the projects from the book. However, it's safe to say that I wasn't quite satisfied with the results. I was too afraid to do changes because I didn't quite understand what was happening. I then ended up taking a hiatus from Django, until recently. 


Fast forward two years and I had more experience with Python itself. I understood OOP (Object Oriented Programming) a lot better, I understood dealing with multiple Python modules better, and was overall more seasoned at Python than I was two years ago. It's also worth mentioning that Django had undergone a major version update and that simplified things A LOT. 

I started following Corey Schafer's Django tutorial series on YouTube, and it was amazing.

What really helped me though was the fact that I was learning visually - as opposed to reading - for one, and Corey's thorough teaching method where he spends a lot of time explaining the hows of something as opposed to simply "Write this and voila". It really helps to get a grasp of what's happening under the hood, and why are you doing something as opposed to just doing it. 

Following his series, I put together the Django web app which was similar to the blog project from the book two years ago, but a lot more functional and feature-rich. Handling multiple user authentication, databases, etc. gave me a deeper look into Django and just how much simpler Django 3 was as opposed to Django 1. 

After finishing his series, I was able to make some minor changes by myself, which was a huge leap in confidence considering I was too scared to make any changes to my project from the book. But to get an even deeper understanding on web-frameworks in general, I decided to start Corey Schafer's Flask tutorial series. Essentially we'd build the same app that we built with Django, but with Flask. 

Learning Flask helped me get a better grasp on Django. 

With Flask, you start with a simple "project.py" file. Everything else, you build from the ground up. This is a different approach from Django's batteries-included approach, which is good to get a project up and running, but can still leave you questioning how everything works. With Flask, you end up building a cohesive application from the ground up that works together with blueprints, which ends up with a similar structure to a Django application except that you know exactly what each module does. 

After finishing Corey's Flask and Django tutorials, I feel a lot more confident in the world of web-frameworks. I'm no expert, obviously, but I have a better grasp on how different modules and packages work, and how to get everything work together. I feel a lot more prepared to dive in and explore, building different projects and gaining more hands-on experience. 

I want to give a shout-out to Corey Schafer for putting so much effort into his tutorials and explaining concepts in a really in-depth way, it's tremendously helped me and a lot more others. I highly recommend checking his channel out!

Comments