I Found the Best Django Tutorial

So as I mentioned recently, I’ve decided to work a little more on the basics of Django since I felt like I was missing a few things. I know I can just continue with my blog project, doing things any way I can make them work, but it really bothers me to know that I’m not doing things properly. I’m always after the best way of doing things.

People say that it doesn’t matter how bad your code is; you should just try to build something and then you get better. Maybe that’s true, but I just hate working on something and all the while thinking ‘the way I am doing this is so wrong’. I guess I’m a bit of a perfectionist in some ways and it isn’t always to my benefit.

So I found a few Django tutorials I was interested in. I specifically made sure they used at least Django 2, since I feel that any version earlier than that is going to be too different and I’d rather learn what is current (the current version of Django is 2.2.3).

I completed the official Django tutorial the other day. I did learn a few things I hadn’t known previously, but still didn’t really feel confident. It was a good tutorial but I wanted something that was a little more in-depth.

Now I’ve almost finished Corey Schafer’s YouTube series, which takes you through building a multi-user blog website. This is going to go straight to the highest spot on my resources page for Django because it is awesome. He explains everything really well, including the little pieces that other tutorials kind of just ignore. I hate it when someone makes a tutorial that they claim is aimed at beginners, but then don’t explain everything. It’s lazy to just say ‘okay copy and paste this code, but don’t worry about what it does’.

I should note here that’s it’s fine to clarify that you don’t have to worry about what it does now, and then bring it up again later in the tutorial. But to just never explain it is bad and people who write ‘beginner’ tutorials like that should be ashamed.

Additionally, Corey’s tutorials introduced me to some awesome add-ons such as Crispy Forms, which is some kind of magic that makes your forms look good and provide useful feedback to users depending on their input. (Okay, it’s probably not really magic but it definitely seems like it.) It is super easy to use. You just have to install it:

pip install django-crispy-forms

Add it to your settings.py as an installed app:

INSTALLED_APPS = [
    'django.contrib.admin',
    ...
    'crispy_forms',
]

As of the time the tutorial was made, Crispy Forms uses Bootstrap 2 by default. To make sure it uses Bootstrap 4 (the current version), also put this line in your settings.py file:

CRISPY_TEMPLATE_PACK = 'bootstrap4'

Then whenever you have a template with a form, you can just load crispy forms like this:

{% load crispy_forms_tags %}

And then add the filter to your form:

{{ form|crispy }}

There are a bunch of other interesting tutorials on his channel too. I’ll probably check out the Python and Flask ones next.

I’m now thinking of adding a few extras to my blog project, like incorporating the polls app I made by following the official Django tutorial, since I think that would fit in. I think one big thing that has made me hesitant to add more is lacking an understanding of how apps work within Django. The tutorials I’ve followed before all had only one, so I wasn’t sure how to make different apps work together within one site. I mean, I had ideas, but I always prefer to see things in practice. Pretty early on in Corey’s tutorial he made me start a second app, and I was instantly thrilled that I would get some experience with a multi-app website.

As well as taking you through building a good example of a basic blog website, there are a few videos at the end of the series that guide you through deployment, something which I think is often not covered in enough detail considering what a pain it can sometimes be.

If you follow all the videos after building the website, then you will learn how to deploy to both a Linux server and Heroku, as well as how to configure a custom domain name, enable HTTPS, and set up a AWS S3 for file uploads.

This is the part I’m up to now, and I’ll likely watch the videos but not actually deploy since I’ve already done that with Heroku and I’m happy enough with that for now. I’ve used S3 before too, and I’ve been thinking of hosting my static files in an S3 bucket since I’ve heard that’s a thing people do because it’s apparently super cost-effective.

I’d also be working with AWS if I get the job I’m preparing for so when there’s a chance to incorporate those services in any way then I feel I should take it. But enough about AWS for now.

If anyone is looking for a super easy to follow Django tutorial that actually explains why things are done a certain way then I’d recommend you start here. I have a few more resources I want to take a look at, but I really don’t see them being as in-depth as this course. I’ll update here if I find anything else amazing though, and anything else that I at least find worth doing will be added to my resources page.