{"@attributes":{"version":"2.0"},"channel":{"title":"Matt's Dev Blog","link":"https:\/\/mattsegal.dev\/","description":{},"lastBuildDate":"Tue, 03 May 2022 12:00:00 +1000","item":[{"title":"How I hunt down (and fix) errors in production","link":"https:\/\/mattsegal.dev\/prod-bug-hunt.html","description":"<p>Once you\u2019ve deployed your web app to prod there is a moment of satisfaction: a brief respite where you can reflect on your hard work. You sit, adoringly refreshing the homepage of www.mysite.com to watch it load over and over. It\u2019s beautiful, perfect, timeless. A glittering \u2026<\/p>","pubDate":"Tue, 03 May 2022 12:00:00 +1000","guid":"tag:mattsegal.dev,2022-05-03:\/prod-bug-hunt.html","category":"Programming"},{"title":"How to setup Django with Pytest on GitHub Actions","link":"https:\/\/mattsegal.dev\/django-with-pytest-on-github-actions.html","description":"<p>Someone recently asked me<\/p>\n<blockquote>\n<p>When is a good time to get automated testing setup on a new Django project?<\/p>\n<\/blockquote>\n<p>The answer is \"now\". There are other good times, but now is best. In this post I'll briefly make my case for why, and show you an example of a minimal \u2026<\/p>","pubDate":"Thu, 13 Jan 2022 12:00:00 +1100","guid":"tag:mattsegal.dev,2022-01-13:\/django-with-pytest-on-github-actions.html","category":"Django"},{"title":"My (free) Django monitoring stack for 2022","link":"https:\/\/mattsegal.dev\/django-monitoring-stack.html","description":"<p>You've built and deployed a website using Django. Congrats!\nAfter that initial high of successfully launching your site comes the grubby work of fixing bugs. There are so many things that <s>can<\/s> will go wrong.\nPages may crash with 500 errors in prod, but not locally. Some offline tasks never \u2026<\/p>","pubDate":"Sat, 01 Jan 2022 12:00:00 +1100","guid":"tag:mattsegal.dev,2022-01-01:\/django-monitoring-stack.html","category":"Django"},{"title":"DevOps in academic research","link":"https:\/\/mattsegal.dev\/devops-academic-research.html","description":"<p>I'd like to share some things I've learned and done in the 18 months I worked as a \"Research DevOps Specialist\" for a team of infectious disease <a href=\"https:\/\/www.bmj.com\/about-bmj\/resources-readers\/publications\/epidemiology-uninitiated\/1-what-epidemiology\">epidemiologists<\/a>.\nPrior to this job I'd worked as a web developer for four years and I'd found that the day-to-day had become quite \u2026<\/p>","pubDate":"Sun, 21 Nov 2021 12:00:00 +1100","guid":"tag:mattsegal.dev,2021-11-21:\/devops-academic-research.html","category":"Programming"},{"title":"How to compress images for a webpage","link":"https:\/\/mattsegal.dev\/webpage-image-compressiom.html","description":"<p>Often when you're creating a website, a client or designer will provide you with large images that are 2-5MB in size and thousands of pixels wide.\nThe large file size of these images will make them slow to load on your webpage, making it seem slow and broken<\/p>\n<p>This video \u2026<\/p>","pubDate":"Fri, 14 May 2021 12:00:00 +1000","guid":"tag:mattsegal.dev,2021-05-14:\/webpage-image-compressiom.html","category":"Programming"},{"title":"How to setup Django with React","link":"https:\/\/mattsegal.dev\/django-react.html","description":"<p>It's not too hard to get started with either Django or React. Both have great documentation and there are lots of tutorials online. \nThe tricky part is getting them to work together. Many people start with a Django project and then decide that they want to \"add React\" to it \u2026<\/p>","pubDate":"Sat, 24 Oct 2020 12:00:00 +1100","guid":"tag:mattsegal.dev,2020-10-24:\/django-react.html","category":"Django"},{"title":"How to highlight unused Python variables in VS Code","link":"https:\/\/mattsegal.dev\/pylance-vscode.html","description":"<p>I make a lot of stupid mistakes when I'm working on Python code. I tend to:<\/p>\n<ul>\n<li>make typos in variable names<\/li>\n<li>accidently delete a variable that's used somewhere else<\/li>\n<li>leave unused variables lying around when they should be deleted<\/li>\n<\/ul>\n<p>It's easy to accidentally create code like in the image below \u2026<\/p>","pubDate":"Fri, 09 Oct 2020 12:00:00 +1100","guid":"tag:mattsegal.dev,2020-10-09:\/pylance-vscode.html","category":"Programming"},{"title":"A Django project blueprint to help you learn by doing","link":"https:\/\/mattsegal.dev\/django-survey-project.html","description":"<p>There's an awkward point when you're learning Django where you've done the <a href=\"https:\/\/docs.djangoproject.com\/en\/3.1\/intro\/install\/\">official tutorial<\/a> and maybe built a simple project, like a to-do list, and now you want to try something a little more advanced. People say that you should \"learn by building things\", which is good advice, but it \u2026<\/p>","pubDate":"Sat, 03 Oct 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-10-03:\/django-survey-project.html","category":"Django"},{"title":"Django project blueprint: data model","link":"https:\/\/mattsegal.dev\/django-survey-project-data-model.html","description":"<p>This post is an appendix to my post on <a href=\"https:\/\/mattsegal.dev\/django-survey-project.html\">designing a Django project<\/a>. In this page I explain why I chose to use this data model:<\/p>\n<p><img alt=\"app data model\" src=\"https:\/\/mattsegal.dev\/data-model.png\"><\/p>\n<p>I created this data model by looking at the user journeys and thinking about what data I would need to make them work. Here's \u2026<\/p>","pubDate":"Sat, 03 Oct 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-10-03:\/django-survey-project-data-model.html","category":"Appendix"},{"title":"Django project blueprint: wireframes","link":"https:\/\/mattsegal.dev\/django-survey-project-wireframes.html","description":"<p>This post is an appendix to my post on <a href=\"https:\/\/mattsegal.dev\/django-survey-project.html\">designing a Django project<\/a>. This page shows all the wireframes for the app, with some additional notes for each page.<\/p>\n<h1>Page designs for the user who answers the survey<\/h1>\n\n<p>This section covers the pages required for the \"survey taker\" user journey \u2026<\/p>","pubDate":"Sat, 03 Oct 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-10-03:\/django-survey-project-wireframes.html","category":"Appendix"},{"title":"How to use both camelCase and snake_case in your frontend and backend","link":"https:\/\/mattsegal.dev\/camel-and-snake-case.html","description":"<p>Python uses <code>snake_case<\/code> variable naming while JavaScript favours <code>camelCase<\/code>. \nWhen you're buiding an web API with Django then you'll be using both langauges together. How do you keep your styles consistent? You <em>could<\/em> just use one style for both your frontend and backend, but it looks ugly. Perhaps this \u2026<\/p>","pubDate":"Thu, 24 Sep 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-09-24:\/camel-and-snake-case.html","category":"Django"},{"title":"A breakdown of how NGINX is configured with Django","link":"https:\/\/mattsegal.dev\/nginx-django-reverse-proxy-config.html","description":"<p>You are trying to deploy your Django web app to the internet.\nYou have never done this before, so you follow a guide like <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04\">this one<\/a>.\nThe guide gives you many instructions, which includes installing and configuring an \"NGINX reverse proxy\".\nAt some point you mutter to yourself:<\/p>\n<blockquote>\n<p>What-the-hell is \u2026<\/p><\/blockquote>","pubDate":"Fri, 31 Jul 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-07-31:\/nginx-django-reverse-proxy-config.html","category":"DevOps"},{"title":"How to manage logs with Django, Gunicorn and NGINX","link":"https:\/\/mattsegal.dev\/django-gunicorn-nginx-logging.html","description":"<p>So you want to run a Django app using NGINX and Gunicorn.\nDid you notice that <em>all three<\/em> of these tools have logging options?\nYou can configure <a href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/topics\/logging\/\">Django logging<\/a>, \n<a href=\"https:\/\/docs.gunicorn.org\/en\/latest\/settings.html#errorlog\">Gunicorn logging<\/a>, and <a href=\"https:\/\/docs.nginx.com\/nginx\/admin-guide\/monitoring\/logging\/\">NGINX logging<\/a>.<\/p>\n<p>You just want to see what's happening in your Django app so that you can fix \u2026<\/p>","pubDate":"Sun, 26 Jul 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-07-26:\/django-gunicorn-nginx-logging.html","category":"Django"},{"title":"How to make your Django project easy to move and share","link":"https:\/\/mattsegal.dev\/django-portable-setup.html","description":"<p>You need your Django project to be portable. It should be quick and easy to start it up on a new laptop. \nIf it isn't portable, then your project is trapped on your machine. If it gets deleted or corrupted, then you've lost all your work!\nThis issue comes up \u2026<\/p>","pubDate":"Fri, 24 Jul 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-07-24:\/django-portable-setup.html","category":"Django"},{"title":"Is Django too slow?","link":"https:\/\/mattsegal.dev\/is-django-too-slow.html","description":"<p>Does Django have \"bad performance\"?\nThe framework is now 15 years old. Is it out of date?\nMostly, no. I think that Django's performance is perfectly fine for most use-cases.\nIn this post I'll review different aspects of Django's \"performance\" as a web framework and discuss how you can decide \u2026<\/p>","pubDate":"Fri, 24 Jul 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-07-24:\/is-django-too-slow.html","category":"Django"},{"title":"There's no one right way to test your code","link":"https:\/\/mattsegal.dev\/alternate-test-styles.html","description":"<p>Today I read a Reddit thread where a beginner was stumbling over themself, apologizing for writing tests the \"wrong way\":<\/p>\n<blockquote>\n<p>I'm now writing some unit tests ... I know that the correct way would be to write tests first and then the code, but unfortunately it had to be done this \u2026<\/p><\/blockquote>","pubDate":"Sat, 11 Jul 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-07-11:\/alternate-test-styles.html","category":"Programming"},{"title":"How to find what you want in the Django documentation","link":"https:\/\/mattsegal.dev\/how-to-read-django-docs.html","description":"<p>Many beginner programmers find the <a href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/\">Django documentation<\/a> overwhelming.<\/p>\n<p>Let's say you want to learn how to perform a login for a user. Seems like it would be pretty simple: logins are a core feature of Django. If you <a href=\"https:\/\/www.google.com\/search?q=django+login\">google for \"django login\"<\/a> or <a href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/search\/?q=login\">search the docs<\/a> you see a few \u2026<\/p>","pubDate":"Fri, 26 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-26:\/how-to-read-django-docs.html","category":"Django"},{"title":"How to pull production data into your local Postgres database","link":"https:\/\/mattsegal.dev\/restore-django-local-database.html","description":"<p>Sometimes you want to write a feature for your Django app that requires a lot of structured data that already exists in production. This happened to me recently: I needed to create a reporting tool for internal business users. The problem was that I didn't have much data in my \u2026<\/p>","pubDate":"Sun, 21 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-21:\/restore-django-local-database.html","category":"Django"},{"title":"How to polish your GitHub projects when you're looking for a job","link":"https:\/\/mattsegal.dev\/github-resume-polish.html","description":"<p>When you're going for your first programming job, you don't have any work experience or references to show that you can write code. You might not even have a relevant degree (I didn't). What you <em>can<\/em> do is write some code and throw it up on GitHub to demonstrate to \u2026<\/p>","pubDate":"Wed, 17 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-17:\/github-resume-polish.html","category":"Programming"},{"title":"How to generate lots of dummy data for your Django app","link":"https:\/\/mattsegal.dev\/django-factoryboy-dummy-data.html","description":"<p>It sucks when you're working on a Django app and all your pages are empty.\nFor example, if you're working on a forum webapp, then all your discussion boards will be empty by default:<\/p>\n<p><img alt=\"dummy-threads-empty\" src=\"https:\/\/mattsegal.dev\/dummy-threads-empty.png\"><\/p>\n<p>Manually creating enough data for your pages to look realistic is a lot of work.\nWouldn't \u2026<\/p>","pubDate":"Sun, 14 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-14:\/django-factoryboy-dummy-data.html","category":"Django"},{"title":"How to automatically reset your local Django database","link":"https:\/\/mattsegal.dev\/reset-django-local-database.html","description":"<p>Sometimes when you're working on a Django app you want a fresh start. You want to nuke all of the data in your local database and start again from scratch. Maybe you ran some migrations that you don't want to keep, or perhaps there's some test data that you want \u2026<\/p>","pubDate":"Sat, 13 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-13:\/reset-django-local-database.html","category":"Django"},{"title":"How to automate your Postgres database backups","link":"https:\/\/mattsegal.dev\/postgres-backup-automate.html","description":"<p>If you've got a web app running in production, then you'll want to take <a href=\"https:\/\/mattsegal.dev\/postgres-backup-and-restore.html\">regular database backups<\/a>, or else you risk losing all your data. Taking these backups manually is fine, but it's easy to forget to do it. It's better to remove the chance of human error and automate \u2026<\/p>","pubDate":"Fri, 05 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-05:\/postgres-backup-automate.html","category":"DevOps"},{"title":"An introduction to cloud file storage","link":"https:\/\/mattsegal.dev\/aws-s3-intro.html","description":"<p>Sometimes when you're running a web app you will find that you have a lot of files on your server. All these files will start to feel like a burden. You might worry about losing them all if the server fails, or you might be concerned about running out of \u2026<\/p>","pubDate":"Fri, 05 Jun 2020 11:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-05:\/aws-s3-intro.html","category":"DevOps"},{"title":"How to backup and restore a Postgres database","link":"https:\/\/mattsegal.dev\/postgres-backup-and-restore.html","description":"<p>You've deployed your Django web app to to the internet. Grats! Now you have a fun new problem: your app's database is full of precious \"live\" data, and if you lose that data, it's gone forever. If your database gets blown away or corrupted, then you will need backups to \u2026<\/p>","pubDate":"Thu, 04 Jun 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-06-04:\/postgres-backup-and-restore.html","category":"DevOps"},{"title":"A tour of Django server setups","link":"https:\/\/mattsegal.dev\/django-prod-architectures.html","description":"<p>If you haven't deployed a lot of Django apps, then you might wonder:\nhow do professionals put Django apps on the internet? What does Django typically look like when it's running in production?\nYou might even be thinking <em>what the hell is <a href=\"https:\/\/www.techopedia.com\/definition\/8989\/production-environment\">production<\/a>?<\/em><\/p>\n<p>Before I started working a developer there \u2026<\/p>","pubDate":"Mon, 25 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-25:\/django-prod-architectures.html","category":"Django"},{"title":"Studying programming: where to start","link":"https:\/\/mattsegal.dev\/self-study-starting.html","description":"<p>You have zero programming knowledge and you want to start learning to code.\nWhere do you start?<\/p>\n<p>Maybe you want to learn enough to get yourself a coding job, or you're planning to study computer science in the future and you\nwant to try it out before you start your \u2026<\/p>","pubDate":"Sat, 16 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-16:\/self-study-starting.html","category":"Programming"},{"title":"Studying programming: pace yourself","link":"https:\/\/mattsegal.dev\/self-study-pacing.html","description":"<p>You can learn programming all by yourself and get a coding job. Just you, your laptop and the internet.\nIt's great! You don't have to pay thousands of dollars for a degree and you can work at your own pace.<\/p>\n<p>There's a problem with this approach though: with no teacher \u2026<\/p>","pubDate":"Fri, 15 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-15:\/self-study-pacing.html","category":"Programming"},{"title":"Studying programming: tools or theory?","link":"https:\/\/mattsegal.dev\/self-study-tools-vs-concepts.html","description":"<p>When you're studying web development you have a lot to learn and limited time.\nOne of the hard choices that you'll need to make is whether you learn tools or concepts.\nShould you study data structures and algorithms to be a web developer?\nIt seems kind of esoteric.\nDo you \u2026<\/p>","pubDate":"Sun, 10 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-10:\/self-study-tools-vs-concepts.html","category":"Programming"},{"title":"How to diagnose and fix slow queries with Django Debug Toolbar","link":"https:\/\/mattsegal.dev\/django-debug-toolbar-performance.html","description":"<p>Your Django views are running slowly and you want to make them faster,\nbut you can't figure out what the issue is just by reading the code.\nJust as bad is when you're not sure if you're using the Django ORM correctly - how can you know if the\ncode you \u2026<\/p>","pubDate":"Sat, 09 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-09:\/django-debug-toolbar-performance.html","category":"Django"},{"title":"Studying programming: what to learn next?","link":"https:\/\/mattsegal.dev\/self-study-mindset-enthusiasm.html","description":"<p>A lot of people trying to teach themselves programming have an anxiety\nabout what they should be learning. There is an endless array\nof options - you've seen these ridiculous <a href=\"https:\/\/github.com\/prakhar1989\/awesome-courses\">lists of online courses<\/a>, right?\nThere's too much to learn and not enough time! You don't want to waste time learning \u2026<\/p>","pubDate":"Fri, 08 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-08:\/self-study-mindset-enthusiasm.html","category":"Programming"},{"title":"Keeping your config files valid with Python","link":"https:\/\/mattsegal.dev\/cerberus-config-validation.html","description":"<p>It's common to use a config file for your Python projects:\nsome sort of JSON or YAML document that defines how you program behaves. Something like this:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"c1\"># my-config.yaml<\/span><span class=\"w\"><\/span>\n<span class=\"nt\">num_iters<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"l l-Scalar l-Scalar-Plain\">30<\/span><span class=\"w\"><\/span>\n<span class=\"nt\">population_size<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"l l-Scalar l-Scalar-Plain\">20000<\/span><span class=\"w\"><\/span>\n<span class=\"nt\">cycle_type<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"s\">&quot;long&quot;<\/span><span class=\"w\"><\/span>\n<span class=\"nt\">use_gpu<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"l l-Scalar l-Scalar-Plain\">true<\/span><span class=\"w\"><\/span>\n<span class=\"nt\">plots<\/span><span class=\"p\">:<\/span><span class=\"w\"> <\/span><span class=\"p p-Indicator\">[<\/span><span class=\"nv\">population<\/span><span class=\"p p-Indicator\">,<\/span><span class=\"w\"> <\/span><span class=\"nv\">infections<\/span><span class=\"p p-Indicator\">,<\/span><span class=\"w\"> <\/span><span class=\"nv\">cost<\/span><span class=\"p p-Indicator\">]<\/span><span class=\"w\"><\/span>\n<\/code><\/pre><\/div>\n\n<p>Storing config in a file \u2026<\/p>","pubDate":"Sun, 03 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-03:\/cerberus-config-validation.html","category":"Programming"},{"title":"8 helpful tools for programming on Windows","link":"https:\/\/mattsegal.dev\/windows-setup-programming.html","description":"<p>Software development on Windows can be a pain. Not because of any issues with C#, .NET\nor the operating system, but simply because the tools surrounding your work can be quite clunky by default.\nI'm talking about the lack of a package manager, PowerShell's ugly blue terminal with no tabs \u2026<\/p>","pubDate":"Sat, 02 May 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-05-02:\/windows-setup-programming.html","category":"Programming"},{"title":"Run your Python unit tests via GitHub actions","link":"https:\/\/mattsegal.dev\/pytest-on-github-actions.html","description":"<p>You've written some unit tests for your Python app. Good for you! There are dozens of us, dozens!\nYou don't always remember to run your tests, or worse, your colleagues don't always remember to run them.<\/p>\n<p>Wouldn't it be nice to automatically run unit tests on every commit to GitHub \u2026<\/p>","pubDate":"Mon, 27 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-27:\/pytest-on-github-actions.html","category":"Programming"},{"title":"Simple Django deployment part six: domain setup","link":"https:\/\/mattsegal.dev\/simple-django-deployment-6.html","description":"<p>We're very nearly done deploying our Django app. There's just one more thing we should take care of.\nHaving a raw IP as our website address is kind of yucky, isn't it?\nYou're not going to ask your friend, boss, or mum to visit 23.231.147.88 to check \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 18:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-6.html","category":"Django"},{"title":"Simple Django deployment part five: deployment automation","link":"https:\/\/mattsegal.dev\/simple-django-deployment-5.html","description":"<p>Deploying our Django app involved a lot of different commands, right? It would suck to have to do all that over again, wouldn't it?<\/p>\n<p>Having to manually type all those commands again would be tedious, slow and easy to screw up.\nEven worse, the harder it is to deploy, the \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 17:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-5.html","category":"Django"},{"title":"Simple Django deployment part four: run a service","link":"https:\/\/mattsegal.dev\/simple-django-deployment-4.html","description":"<p>So we've got a problem. Our Django app only runs when we're logged into the server via SSH and running Gunicorn.\nThat's not going to work long term. We need to get Gunicorn running even when we're not around.\nIn addition, if our Gunicorn server crashes because of some bug \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 16:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-4.html","category":"Django"},{"title":"Simple Django deployment part three: deploy code","link":"https:\/\/mattsegal.dev\/simple-django-deployment-3.html","description":"<p>We've got our server set up, and our Django code is ready.\nNow we can actually deploy Django to our server.\nThe goal of this section is to get a basic deployment done.\nWe'll do some automation and introduce some extra tools later.<\/p>\n<p>In this section we'll cover:<\/p>\n<ul>\n<li>Windows line \u2026<\/li><\/ul>","pubDate":"Sun, 26 Apr 2020 15:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-3.html","category":"Django"},{"title":"Simple Django deployment part two: local setup","link":"https:\/\/mattsegal.dev\/simple-django-deployment-2.html","description":"<p>We've got our server set up and ready to host our Django app, now let's focus on preparing our app for deployment.\nThe goal of this section is to set up and test as much of the stuff that we'll be using in production.\nThat way, we can debug issues \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 14:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-2.html","category":"Django"},{"title":"Simple Django deployment part one: infrastructure","link":"https:\/\/mattsegal.dev\/simple-django-deployment-1.html","description":"<p>In order to deploy our Django app, we need a somewhere to run it: we need a server.\nIn this section we'll be setting up our server in \"the cloud\".\nDoing this can be fiddly and annoying, especially if you're new, so we want to get it right first before \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 13:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment-1.html","category":"Django"},{"title":"Simple Django deployment: a guide","link":"https:\/\/mattsegal.dev\/simple-django-deployment.html","description":"<p>You're learning web development with Django. You've followed the <a href=\"https:\/\/docs.djangoproject.com\/en\/3.0\/intro\/tutorial01\/\">official introductory tutorial<\/a> and you can get a Django app working on your local computer. Now you want to put your web app onto the internet. Maybe it's to show your friends, or you actually want to use it for something \u2026<\/p>","pubDate":"Sun, 26 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-26:\/simple-django-deployment.html","category":"Django"},{"title":"Never think about Python formatting again","link":"https:\/\/mattsegal.dev\/python-formatting-with-black.html","description":"<p>At some point you realise that formatting your Python code is important.\nYou want your code to be readable, but what's the <em>right<\/em> way to format it?\nYou recognise that it's much harder to read this:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"n\">some_things<\/span> <span class=\"o\">=<\/span> <span class=\"p\">{<\/span><span class=\"s2\">&quot;carrots&quot;<\/span><span class=\"p\">:<\/span> <span class=\"p\">[<\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span><span class=\"mi\">2<\/span> <span class=\"p\">],<\/span>\n<span class=\"s2\">&quot;apples&quot;<\/span><span class=\"p\">:[<\/span>\n<span class=\"mi\">3<\/span><span class=\"p\">,<\/span><span class=\"mi\">3<\/span><span class=\"p\">,<\/span> <span class=\"mi\">3<\/span>\n<span class=\"p\">],<\/span> <span class=\"s2\">&quot;pears&quot;<\/span><span class=\"p\">:<\/span> <span class=\"p\">[]<\/span> <span class=\"p\">}<\/span>\n<\/code><\/pre><\/div>\n\n<p>than it is to \u2026<\/p>","pubDate":"Fri, 24 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-24:\/python-formatting-with-black.html","category":"Programming"},{"title":"Cloudflare makes DNS slightly less painful","link":"https:\/\/mattsegal.dev\/cloudflare-review.html","description":"<p>When you're setting up a new website, there's a bunch of little tasks that you have to do that <em>suck<\/em>.\nThey're important, but they don't give you the joy of creating something new, they're just... plumbing.<\/p>\n<p>In particular I'm thinking of:<\/p>\n<ul>\n<li>setting up your domain name with DNS records<\/li>\n<li>encrypting \u2026<\/li><\/ul>","pubDate":"Sat, 18 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-18:\/cloudflare-review.html","category":"DevOps"},{"title":"Nand to Tetris is a great course","link":"https:\/\/mattsegal.dev\/nand-to-tetris.html","description":"<p>Everyone who learns programming at some point stops and asks - how does this actually work?\nYou might know how to write and run code, but <em>what's actually happening inside the computer<\/em>?\nIt can seem unfathomable.<\/p>\n<p>Some people don't care about what's happening under the hood. Their code works, it gets \u2026<\/p>","pubDate":"Fri, 17 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-17:\/nand-to-tetris.html","category":"Programming"},{"title":"DNS for beginners: how to give your site a domain name","link":"https:\/\/mattsegal.dev\/dns-for-noobs.html","description":"<p>You are learning how to build a website and you want to give it a domain name like mycoolwebsite.com.\nIt doesn't seem like a <em>real<\/em> website without a domain name, does it?\nHow is anybody going to find your website without one?\nSetting up your domain is an important \u2026<\/p>","pubDate":"Mon, 13 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-13:\/dns-for-noobs.html","category":"DevOps"},{"title":"4 tips for debugging in Django","link":"https:\/\/mattsegal.dev\/django-debug-tips.html","description":"<p>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.<\/p>\n<h3>Dig deeper in your \u2026<\/h3>","pubDate":"Sun, 12 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-12:\/django-debug-tips.html","category":"Django"},{"title":"Quickly fix bugs in Django with Python's debugger","link":"https:\/\/mattsegal.dev\/django-debug-pdb.html","description":"<p>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:<\/p>\n<ul>\n<li>Add a \"print\" statement to your code<\/li>\n<li>Refresh the page in your browser to re-run your code<\/li>\n<li>Look at the <code>runserver<\/code> console output for the \"print \u2026<\/li><\/ul>","pubDate":"Sat, 11 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-11:\/django-debug-pdb.html","category":"Django"},{"title":"How to view Django logs with Papertrail","link":"https:\/\/mattsegal.dev\/django-logging-papertrail.html","description":"<p>You have a Django app running on a webserver and hopefully you're <a href=\"https:\/\/mattsegal.dev\/file-logging-django.html\">writing your logs to a file<\/a>. If anything goes wrong you can search back through the logs and figure out what happened.<\/p>\n<p>The problem is that to get to your logs, you have to log into your server \u2026<\/p>","pubDate":"Fri, 10 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-10:\/django-logging-papertrail.html","category":"Django"},{"title":"How to save Django logs in production","link":"https:\/\/mattsegal.dev\/file-logging-django.html","description":"<p>You've deployed Django to a webserver and something has broken. There's an error <em>somewhere<\/em>. 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 \u2026<\/p>","pubDate":"Fri, 10 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-10:\/file-logging-django.html","category":"Django"},{"title":"How to customise a class based view in Django","link":"https:\/\/mattsegal.dev\/customise-class-based-view-django.html","description":"<p>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 \u2026<\/p>","pubDate":"Thu, 09 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-09:\/customise-class-based-view-django.html","category":"Django"},{"title":"9 commands for debugging Django in Docker containers","link":"https:\/\/mattsegal.dev\/docker-container-debugging.html","description":"<p>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!<\/p>\n<p>A few days later there's an error in your code and you want to debug \u2026<\/p>","pubDate":"Wed, 08 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-08:\/docker-container-debugging.html","category":"DevOps"},{"title":"Introduction to configuration management","link":"https:\/\/mattsegal.dev\/intro-config-management.html","description":"<p>This is a talk I gave at the Melbourne <a href=\"https:\/\/www.meetup.com\/en-AU\/Junior-Developers-Melbourne\/\">Junior dev meetup<\/a>:<\/p>\n<blockquote>\n<p>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 \u2026<\/p><\/blockquote>","pubDate":"Wed, 08 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-08:\/intro-config-management.html","category":"DevOps"},{"title":"Sentry is great for tracking Django errors","link":"https:\/\/mattsegal.dev\/sentry-for-django-error-monitoring.html","description":"<p>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!?<\/p>\n<p>Even worse is when a <em>customer<\/em> experienced an error 12 hours ago and <em>you<\/em> need to figure out \u2026<\/p>","pubDate":"Wed, 08 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-08:\/sentry-for-django-error-monitoring.html","category":"Django"},{"title":"3 ways to deploy a Django backend with a React frontend","link":"https:\/\/mattsegal.dev\/django-spa-infrastructure.html","description":"<p>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:<\/p>\n<ul>\n<li>Do \u2026<\/li><\/ul>","pubDate":"Tue, 07 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-07:\/django-spa-infrastructure.html","category":"Django"},{"title":"How to restart Celery on file change","link":"https:\/\/mattsegal.dev\/restart-celery-on-file-change.html","description":"<p>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 <code>runserver<\/code> restarts on code change, why can't Celery? How can you set up your dev envrionent to force Celery to \u2026<\/p>","pubDate":"Tue, 07 Apr 2020 12:00:00 +1000","guid":"tag:mattsegal.dev,2020-04-07:\/restart-celery-on-file-change.html","category":"Django"},{"title":"How to deploy Django migrations","link":"https:\/\/mattsegal.dev\/deploy-django-migrations.html","description":"<p>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.<\/p>\n<p>How do you deploy those model \u2026<\/p>","pubDate":"Sat, 04 Apr 2020 12:00:00 +1100","guid":"tag:mattsegal.dev,2020-04-04:\/deploy-django-migrations.html","category":"Django"},{"title":"Fix long running tasks in Django views","link":"https:\/\/mattsegal.dev\/offline-tasks.html","description":"<p>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.<\/p>\n<p>Sometimes \u2026<\/p>","pubDate":"Thu, 02 Apr 2020 12:00:00 +1100","guid":"tag:mattsegal.dev,2020-04-02:\/offline-tasks.html","category":"Django"},{"title":"Simple scheduled tasks with Django Q","link":"https:\/\/mattsegal.dev\/simple-scheduled-tasks.html","description":"<p>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.<\/p>\n<p>There are a lot of reasons you might want to run code on a schedule. You may want to:<\/p>\n<ul>\n<li>Process a \u2026<\/li><\/ul>","pubDate":"Mon, 30 Mar 2020 12:00:00 +1100","guid":"tag:mattsegal.dev,2020-03-30:\/simple-scheduled-tasks.html","category":"Django"}]}}