Where to define and instantiate associated models in Django

For the sake of example, let's consider the following UML diagram describing two model classes and how they are interrelated: We can see that there are two classes, User and UserProfile, with a one-to-one association between them. That is, each instance of class User is associated with one and only one instance of UserProfile and [...]

Streamlining radio buttons and checkboxes with CSS & Font Awesome

The appearance of radio buttons and checkboxes differs quite a lot between different browsers. Luckily, there are a number of ways to streamline the look of these input elements across browsers. One of them involves a combination of HTML, pure CSS and Font Awesome icons. HTML structure & icons The required HTML structure consists of [...]

Creating a persistent Arch Linux installation on a USB stick

I've been using Arch Linux for the better part of a decade now. As a result, I am so used to it that I'll choose it for nearly any task at hand. Although Arch might not be a traditional distribution for persistent live systems, there's really no reason to not use it to this purpose. [...]

Writing an ISO disk image directly from the Internet to a device

Disk images tend to be large yet available disk space remains a scarce resource even in times of multi-terabyte devices. For this reason, it can still be handy to retrieve a disk image from the Internet and write it to a device without having to temporarily store it on your disk. The below command will [...]

Building a Java JSON API in 4 minutes (yes, 4 minutes)

So you have written this amazing piece of software solving one of the world's biggest problems. If only you could quickly & painlessly share the fruits of your labor with the world… Well, actually you can, and it's not that hard. Quite the contrary: It's really simple, thanks to Spark1 which (according to its website) [...]

Adding type information to exported Scrapy items

By default, Scrapy won't include any type information when using feed exports to serialize scraped items. It follows that, when exporting multiple types of items at once, we later on can't easily discern between the different concepts represented by the items. Consider the following items.py module: import scrapy class AnimalItem(scrapy.Item) name = scrapy.Field() class CatItem(AnimalItem) [...]

Running background tasks in Django

For modern web applications, running asynchronous tasks in the background is, more often than not, a must. Whether you need to parallelize something not-so-time-critical (say, thumbnail generation) or access that miraculous-but-really-slow machine learning API in the background, there is a plethora of other use cases that require the developer to isolate time-consuming operations from Django's [...]

Hosting a Django application with Apache’s mod_wsgi

According to Django's documentation, “deploying Django with Apache and mod_wsgi is a tried and tested way to get Django into production”. Let's hope they are right. Install mod_wsgi: Obviously, this step depends on your package manager (which is usually determined by your distribution). On Arch Linux it goes something like this: sudo pacman -Sy mod_wsgi [...]