Learning Django: Thoughts and Suggestions

Feature image

Learning Django: Thoughts and Suggestions

Published March 11, 2021

When I started programming in 2014 through a course at university, we ended the term by constructing desktop applications in Java. This certainly was interesting and Java is a great language to start learning some of the fundamentals of programming (e.g. object-orientated programming, primitive types, data-structures) without needing to worry too much about memory management. However the magic I saw in computer science wasn't with desktop applications but what was capable with the web.

As a kid I was amazed by how I could communicate with someone in another country from the school's computer or that I could play hundreds of Flash games without needing to buy a single disk or cartridge! It really seemed like the future was on the web, and after looking at all the technical achievements made in recent years, it seems that hunch came true. In university I developed a few web applications using tools such as Apache Tomcat and Spring that were written in Java yet I always had an issue with how many key strokes it took to get things done in Java. It wasn't until a few years ago when I picked up Python that I felt I could finally get projects up and running in a decent time! After becoming comfortable with the specifics of Python itself I decided to take up web development in earnest. There are two main web frameworks that are built on Python: Django and Flask. After comparing the two I decided I'd try to learn Django which I've been doing for almost a year now.

For any type of project it is good to reflect back on its progress and to recount what you've learned - what worked and what didn't, what was easier to do and what was harder. In this post I'm going to share my some of my thoughts on my learning experience and some suggestions if you're new to Django. This is a good time for me to reflect as I've just finished my first self-project in Django: HikeNote. While it is functioning (if you find any issues let me know!) it was more of a demo/toy than an actual product. It was especially helpful in the context of learning as I'll discuss towards the end of this post.

Prerequisites: What To Know First

Let's start with core programming skills. Things such as iteration (for-loops, while loops) over a collection, conditionals (if-statements, logic fundamentals), primitive objects and datatypes (Strings, integers, floats), constructing objects, the extension of objects (inheritance) and defining object fields and methods, are all things you should be comfortable with first. If you have experience in a statically-typed language (such as C++ or Java) the move to Python should be easy, perhaps too easy; most of your time adjusting may be adjusting to how certain operations can be  done in Python and getting a customed to the syntax. I would also recommend using a package manger when working with Django (and anything in Python!) Checkout pip or anaconda - Django can be installed with these tools along with other packages that can add many features to your applications.

Now onto databases. Chances are your application is going to need a way to store and maintain data. Django offers easy ways to use both relational and non-relational databases through its model component (Django is built around the Model-View-Template design principle, something you'll learn.) In fact although you can send statements directly to your database (in a language such as SQL,) you can get away with only writing Python classes and functions to do so! Despite this, it will be good have some understanding of databases, specifically the type you will use. One thing you must know if you'll have several tables in your database is how tables can relate to one another (e.g. one-to-one, many-to-one, many-to-many relationships.)

Finally you should have an understanding of HTTP and HTML. The frontend will be the way people interact with your application which relies on both of these. For example, user's may submit data that will eventually end up in your applications database through an HTML form via a HTTP POST method. Django has its own way of managing the webpages (templates) that are built on top of HTML. While not needed, I would also recommend knowing how to style your webpages through CSS. If you're like me and prefer the backend to the frontend, knowing how to use frameworks such as Bootstrap or Semantic UI will be sufficient to get your pages to look nice during developmenet.

Diving In: Resources That Work For Me

Let's start coding. When learning new coding languages/libraries I have found that diving right into coding to be quickest way to pick them up. For this reason I've found that following along with video tutorials, where an instructor types the code in real time, to be best. Below I'll recommend a few free tutorials on YouTube that worked for me, but I'll first warn you about falling into the tutorial trap.

You don't want to just learn Django, you want to develop a skillset to create applications that use Django. I view the process to develop these skills as a cyclic, two-phase routine that you practice until, well, you give up on Django; it is a process that never really stops. The first phase is the learning phase where you understand how to preform certain operations in Django. This is what you understand through following along with other coders. The second phase is the application phase where you apply your current understanding to create something from the ground up. The tutorial trap is failing to move from the learning phase to the application phase. It is crucial to develop your own applications; not only does it check your current understanding, but it will show you what you don't know - what skills you need to build on when you return to the learning phase. Watch a few tutorials and when you start to predict what comes next it may be time to build your own project. This project does not need to huge, in fact I'd recommend something small that could be completed within a week. Be a little ambitious, try to push your knowledge when planning what your application will be. Also keep a journal of the project - from the initial planning, to what was easy and what was hard to implement. It will be a useful resource to reflect back on when deciding what to learn next.

CodeMy - Simple Django Blog

John Elder at codemy.com is an experienced coder and instructs several courses online. While I haven't viewed his other courses, I would recommend his Django blogs tutorial as your first tutorial. It covers a wide range of Django features and is excellent for getting familiar with the framework. While his videos aren't "too slow", he moves at just the right rate for beginners.

Dennis Ivy - Django (3.0) Crash Course

Dennis' crash course in Django is also another great series for beginners. His presentation style is clear and concise resulting in short but content rich videos. The application, a customer/order dashboard, provides an interesting implementation that is something you'd likely encounter in a professional setting.

Pyplane - Social Network

Lukasz Makinia walks through the creation of a social media application in Django with semantic UI on the front end. This is a great tutorial as it moves past some of the more "basic" tasks that are the core of the earlier tutorials and into more advance topics. After completing it (along with the afore mentioned tutorials) I felt ready to create my own project from scratch. Lukasz's presentation style is also concise and fast; I definitely recommend it once you have a basic understanding of Django and are looking for a more intermediate-level tutorial.

These are tutorials that I can recommend from my own personal experience yet a quick YouTube search will show you there are countless courses available to you! Although I haven't gone into these courses, I've heard those by Traversy Media and Corey Schafer are quite good as well. Additionally if reading is your preferred way to learn, I can highly recommend Antonio Mele's Django 3 By Example textbook. It walks you several applications which cover a variety of concepts.

Finally, I'd like to mention one thing that all of these tutorials fail to provide. None cover the planning of applications, that which you do before typing a single line of code. While this is understandable, it is good to keep it in mind when going through them. Chances are their creators have already designed and implemented a final version of the project. In my experiences with developing not only Django application but other projects, things are never this straight forward. Yes you should have clear vision of what it is you plan to build first, but do expect (especially if you're new to creating things) for issues to arise during development. Remember that its all apart of developing your skill set.

 

Best of luck learning Django!

Reply to this article