DictSort Template FilterWed Jan 05 2022

In this Django Primer, we will look at the dictsort template filter, as well as the dictsortreversed template filter, and see how these can be used to order dictionaries in your Django template by a specific key.

Introduction to Alpine.jsSun Jan 02 2022

In this post, we will introduce the Alpine.js library - this is a lightweight JavaScript framework for building interactive applications that circumvents the need for complex JavaScript tooling. It's directives are inspired by Vue.js, but Alpine.js has a more minimal set of functionality, making it a good option for building interactive apps with minimal JavaScript overhead.

Creating Scheduled Tasks with Django-CrontabSun Jan 02 2022

In this video we'll demonstrate how to create a scheduled task using the django-crontab package. We will create a task that fetches cryptocurrency data from the CoinMarketCap API and updates the database. We will also demonstrate how to set these cronjobs up within a Docker container that runs our Django application

Python Primers - Moving Old Files To ZIP ArchivesWed Dec 29 2021

In this Python Primer, we will walk through the process of moving all files in the current directory that are older than a certain date to a ZIP file.

Django and HTMX Forms - with django-forms-dynamicWed Dec 29 2021

In this post, we'll look at a new Django Form library called django-forms-dynamic. This library "resolves form field arguments dynamically when a form is instantiated, not when it's declared" - allowing dynamic forms to be created, where the values of one field can be dependent on another. This makes the library suitable for use with tools such as HTMX and Unpoly.

Django, Bokeh and HTMX - Data Driven Line ChartsTue Dec 28 2021

In this video, we will create a dynamic, database-driven LINE chart for a country's historical GDP data. We will use Django for our backend functionality, will use Bokeh to create a line chart showing the trajectory of this GDP data, and will use HTMX to dynamically filter the country whose data is shown on the chart. We will also show how to create multi-line charts using Bokeh.

Django, Bokeh and HTMX - Data Driven Bar ChartsMon Dec 27 2021

In this video, we will create a dynamic, database-driven bar chart for country GDP data. We will use Django for our backend functionality, will use Bokeh to create bar charts representing the GDP data, and will use HTMX to dynamically filter the year for which data is shown.

Django and HTMX Chained DropdownThu Dec 16 2021

In this video, we build a simple chained dropdown using Django and HTMX. We will look at a simple scenario where the first dropdown contains a set of university courses, and the second dropdown contains a set of modules for that course. The contents of the second dropdown depend on the selection of the first dropdown, and we will use HTMX to perform actions when an option in the first dropdown is selected.

Python Filesystem OperationsTue Dec 07 2021

In this post, we will demonstrate how to perform certain actions on the filesystem, such as listing files and directories, listing all files with a particular extension/type, sorting files alphabetically, sorting files by the file size, and creating a ZIP file from selected files.

Scraping Historical Champions League DataFri Dec 03 2021

In this post, we will use the BeautifulSoup and requests libraries in Python to scrape historical Champions League data, from a specific year until the present day. This post will be the basis for a future post, where we plot out a bar-chart-race based upon this scraped data.

Django and HTMX Live Scores Project #2Thu Dec 02 2021

In this post, we'll extend our application to include HTMX-driven search functionality and visual feedback to the user when HTMX polling requests are updating the UI.

Django and HTMX Live Scores ProjectWed Dec 01 2021

In this post, we will build an application using Django and HTMX that simulates live sports scores streaming into a webpage. The application will use HTMX's polling capabilities for this, and will dynamically update a frontend page with new scores and full-time results as they come in.

NASA CLI App with Python - Concurrent Requests with Asyncio and HTTPXFri Nov 26 2021

In this post, we will convert our sequential network requests to a more efficient, concurrent model, using the HTTPX library for network calls, and the standard-library's asyncio module.

NASA CLI App with Python - Fetching Range of ImagesWed Nov 17 2021

In this tutorial, we will extend our setup to give users the ability to fetch images between a start date and an end date. We will add these two CLI options to our Typer command, and will use these to determine the action that the command should take.

NASA CLI App with Python - Fetching ImagesWed Nov 17 2021

This post will extend the original Typer tutorial to fetch images from the NASA API, and display them on the user's desktop. We will make use of a new Typer command, and will add default arguments and the ability to parse both JSON and bytes (image) responses from NASA's API.

NASA CLI App with Typer and PythonWed Nov 17 2021

In this post, we will explore the Typer package, which is a modern package for developing command-line applications in Python. Typer provides decorators for defining commands, and uses modern Python type-hinting for command-line arguments and options.

Django and HTMX - Delete PageWed Nov 03 2021

In this post, we'll extend the list/create page to give users the ability to delete films from their list. We will do this using HTMX, using AJAX requests to remove the film from the users list and insert the returned template into the DOM without refreshing the page

Django and HTMX - List And Create Page (with no refreshes!)Tue Nov 02 2021

In this post, we will build a page allowing users to list out their favourite movies, and add new movies to their list. This will work without any page refreshes, affording the user a better and more reactive experience, thanks to HTMX.

NetworkX - Algebraic Connectivity, Bridges, and Connected ComponentsSun Oct 31 2021

In this post, we will analyze the algebraic connectivity of a graph, and will understand how this value relates to the connectivity of the graph. We will also dive into some core graph theory concepts, such as graph density, connected components and graph bridges in this post. We will see how to use NetworkX to analyze these core concepts.

Django and HTMX Trigger Modifiers & CSS TransitionsSat Oct 30 2021

In this post, we will learn how to use trigger modifiers and CSS transitions in HTMX. We will extend the previous tutorial's example, and demonstrate how to add trigger modifiers to the keyup event on our registration form's username field. We will also use CSS transitions to animate the message displayed to the user.

Django and HTMXSun Oct 24 2021

In this post, we will take a look at an example of using HTMX within a Django application. Using HTMX allows us to perform AJAX requests to our Django backend and swap out content in the DOM - all without writing a single line of JavaScript.

Creating Graphs with NetworkXSat Oct 23 2021

This post looks at how to create simple, undirected graphs in NetworkX, and looks at the utilities the library provides for adding and removing nodes and edges from a graph. We also look at how to inspect basic features of a graph, such as its nodes, edges, degrees of nodes, and node neighbors.

Properties of the Laplacian MatrixThu Oct 21 2021

In this post, we will look at some algebraic properties of the Laplacian matrix, using tools provided by NetworkX and Numpy.

The Laplacian MatrixThu Oct 21 2021

This post will look at the basic, unnormalized Laplacian matrix of a graph - specifically, we will look at a 3-regular graph. We will see how to manually compute the laplacian from the Degree Matrix and the Adjacency Matrix of a graph, and will subsequently see how to derive the Laplacian Matrix with a networkx function.

Uploading Files with Django NinjaSun Oct 10 2021

This short post will demonstrate how to upload files, using the django-ninja API library.

Treemaps in Python with Football DataTue Sep 21 2021

In this post, we scrape data from the English Premier League 2020/21, and plot the goals scored by each team as a treemap visualization in Python. We use the Squarify library, in concert with Matplotlib, to plot and customize treemaps. Finally, we show an alternative visualization for the goals scored - a horizontal barplot.

Modelling Euro 2020 Results with Python Dataclasses #2Tue Sep 14 2021

This post follows from the previous post, where we model Euro 2020 data scraped from the BBC website as Python dataclasses. In this post, we'll create a TeamStats class to model a team's tournament statistics, such as the number of goals they scored and conceded, the number of games won, drawn and lost, and the number of games that went to penalties.

Modelling Results with Python DataclassesTue Sep 14 2021

In this post, we'll look at how to model the data scraped in the "Scraping Football Data with Beautiful Soup In Python" post using Python's dataclasses. We'll create a Result class that can encapsulate information about the team names and goals scored in a given match at the Euro 2020 Championships.

Setting up SQLModelWed Sep 08 2021

In this second part of our music track API series, we will look at how to add the new SQLModel package to our application. Specifically, we look at how to set up a SQLite database using SQLModel, allowing us to create a table for our music tracks based on a type-hinted schema. We then modify our FastAPI startup event to load the track data into our database table.

Creating A Music Track API with FastAPI in PythonTue Sep 07 2021

This post outlines how to use the basic features of FastAPI to create a music tracks CRUD API. We create endpoints that allow us to get music tracks, get a single music track, as well as create, update and delete tracks. This is the first post in a short series, where we delve into the FastAPI ecosystem - in the next post, we'll adapt the API to use a relational database and use the shiny new SQLModel package!

Scraping Football Data with Beautiful Soup In PythonTue Aug 31 2021

In this post, we will look at how to scrape the football/soccer results from the Euro 2021 Championships, using the BeautifulSoup web scraping library for Python.

Refactor Clinic #3Fri Aug 27 2021

In this post, we will demonstrate how to refactor code that searches for a given dictionary within a list of dictionaries. By cleaning up the code, we will highlight different constructs available in Python, to help developers get a better understanding of the overall language, and understand where certain features can be applied.

Refactor Clinic #2Fri Aug 27 2021

In this post, we will demonstrate how to refactor code that extracts the values of attributes on a Python object (class) to a dictionary with the same key names. By cleaning up the code, we will highlight different constructs available in Python, to help developers get a better understanding of the overall language, and understand where certain features can be applied.

Refactor Clinic #1Fri Aug 27 2021

In this post, we will demonstrate how to refactor a Python function to perform the same functionality, but in a cleaner and more concise manner. By cleaning up the code, we will highlight different constructs available in Python, to help developers get a better understanding of the overall language, and understand where certain features can be applied.

OpenStreetMap, Folium and GeoPy for Mapping and Distance FindingFri Aug 20 2021

In this tutorial, we will look at how to convert ZIP-codes to latitude and longitude coordinates using an OpenStreetMap API lookup, and will learn how to plot these coordinates on a Leaflet map using Python's excellent Folium library. We will also find out how to calculate the distance between two geographical points, using the GeoPy library, and will look at how to find the mid-point between two points with some Python code.

Python Ternary ExpressionsWed Aug 18 2021

This post will outline Python's equivalent to the ternary expressions found in other languages such as C, Java and JavaScript. In Python, conditional expressions allow ternary-like logic to be expressed, giving programmers the ability to define single-line conditional logic.

Lambda Functions in PythonFri Aug 13 2021

This post introduces Lambda Functions in Python, and demonstrates their usage with a few examples. Firstly, we create a lambda to represent Einstein's famous equation, E = mc^2. Secondly, we create a lambda function to calculate a company's corporation tax bill based on their income and expenses. And finally, we demonstrate a common use of lambda functions - as parameters to other Python functions such as sorted(), min() and max().

Django-Ninja - Creating a CRUD APITue Aug 10 2021

The second part of the django-ninja series - we look at extending our Music Track API to a full CRUD API, by creating an endpoint for creating music tracks (POST), changing existing music tracks (PUT) and deleting existing music tracks (DELETE).

List ComprehensionsMon Aug 09 2021

This conceptual post will demonstrate how to use list comprehensions to cut down on code, and express iterative logic in a concise, Pythonic manner. We look at examples involving lists of numbers and lists of strings (berries!), and show how to achieve results using list comprehensions.

Django-Ninja - An IntroductionSun Aug 08 2021

In this post, we create a few endpoints Music Track API using django-ninja - a nice alternative to Django REST Framework that is heavily inspired by the FastAPI web framework. We show how easy it is to wire up API routes and retrieve (and serialize) data using the Django ORM and django-ninja Schema objects.

Django-Unicorn - An IntroductionSat Jul 31 2021

This post will demonstrate some of the features and concepts offered by the django-unicorn library, an interactive library for creating rich components in Django, which minimizes the JavaScript footprint involved in creating dynamic user interface components. We will build a movie list component, that allows the user to dynamically add to a list of movies and delete movies from their templates - all without writing any AJAX calls.

Application Configuration with django-environWed Jul 28 2021

This post will demonstrate some best practices in configuring Django applications. We will look at the 12 Factor approach for configuration, and will learn about the django-environ package that helps to secure applications using environment variables, safe defaults, and type-casting.

Django - custom User modelSun Jul 18 2021

This post will outline different approaches for customizing Django's default User model, and will demonstrate how to extend this model with new fields, and how to remove existing User model fields that you do not need. We will pay close attention to two abstract classes in Django - AbstractUser and AbstractBaseUser - that both enable flexible extensions of Django's User system.

Django SESMon Jul 12 2021

This post will demonstrate how to integrate Amazon SES with Django applications, for sending emails. You will learn how to configure SES, how to use the django-ses library, and how to send test emails from Django to ensure your setup works as expected.

;