Matt's Dev Blog

Never think about Python formatting again

At some point you realise that formatting your Python code is important. You want your code to be readable, but what's the right way to format it? You recognise that it's much harder to read this:

some_things = {"carrots": [1,2 ],
"apples":[
3,3, 3
], "pears": [] }

than it is to …

Cloudflare makes DNS slightly less painful

When you're setting up a new website, there's a bunch of little tasks that you have to do that suck. They're important, but they don't give you the joy of creating something new, they're just... plumbing.

In particular I'm thinking of:

  • setting up your domain name with DNS records
  • encrypting …

Nand to Tetris is a great course

Everyone who learns programming at some point stops and asks - how does this actually work? You might know how to write and run code, but what's actually happening inside the computer? It can seem unfathomable.

Some people don't care about what's happening under the hood. Their code works, it gets …

DNS for beginners: how to give your site a domain name

You are learning how to build a website and you want to give it a domain name like mycoolwebsite.com. It doesn't seem like a real website without a domain name, does it? How is anybody going to find your website without one? Setting up your domain is an important …

4 tips for debugging in Django

You've got a bug in your Django code and you can't quite figure out what's wrong. You know there's a problem, but you can't quite pin down where it's coming from. This post will share 4 tips which will help you speed up your bug catching.

Dig deeper in your …

Quickly fix bugs in Django with Python's debugger

There's a bug in your Django code. You've tried to track down the problem with "print" statements, but it's such a slow, tedious process:

  • Add a "print" statement to your code
  • Refresh the page in your browser to re-run your code
  • Look at the runserver console output for the "print …

How to view Django logs with Papertrail

You have a Django app running on a webserver and hopefully you're writing your logs to a file. If anything goes wrong you can search back through the logs and figure out what happened.

The problem is that to get to your logs, you have to log into your server …

How to save Django logs in production

You've deployed Django to a webserver and something has broken. There's an error somewhere. What happened? When you're debugging Django on your local computer, you can just throw a print statement into your code and check the output in the runserver logs. What about in production? Where do the logs …

How to customise a class based view in Django

You've spend a little bit of time working on your Django app and you want to dip your toes into class-based views. The basic examples are simple enough, but once you want to do something more complicated, something more custom, you get stuck. How do you customise a class-based view …

9 commands for debugging Django in Docker containers

You want to get started "Dockerizing" your Django environment and you do a tutorial which shows you how to set it all up with docker-compose. You follow the listed commands and everything is working. Cool!

A few days later there's an error in your code and you want to debug …

Introduction to configuration management

This is a talk I gave at the Melbourne Junior dev meetup:

Have you ever found a bug in prod, which wasn't caught earlier because of a missing folder, library, or file permission? It sucks! This talk goes over some practices and tools that you can use to keep your …

Sentry is great for tracking Django errors

You've deployed a Django app to a webserver and now it's not working. Your app is throwing 500 Internal Server Errors - what's wrong? Why is this happening? It worked on my laptop!?

Even worse is when a customer experienced an error 12 hours ago and you need to figure out …

3 ways to deploy a Django backend with a React frontend

You're developing a web app with a Django REST backend and some sort of single page app frontend using React or Vue or something like that. There are many ways for you to run this app in production. There are a lot of choices that you need to make:

  • Do …

How to restart Celery on file change

I use Celery and Django together a lot. My biggest pain when doing local development with Celery is that the worker process won't restart when I change my code. Django's runserver restarts on code change, why can't Celery? How can you set up your dev envrionent to force Celery to …

How to deploy Django migrations

You've started learning Django, you've created a new Django app and you've deployed it to a Linux webserver in the cloud somewhere. It's all set up and running nicely. Now you want to make some more changes and you need to update your models.

How do you deploy those model …

Fix long running tasks in Django views

What do you do if you have a Django view that runs too slow? Slow views are a bad user experience. Users hate waiting. Even worse, if the view takes too long to return a response, they will receive a "408 Request Timeout" error, completely ruining the website experience.

Sometimes …

Simple scheduled tasks with Django Q

How do you run some code once a day in Django, or every hour? This post will explain how to set up scheduled code execution in Django using Django-Q.

There are a lot of reasons you might want to run code on a schedule. You may want to:

  • Process a …

Page 3 / 3