Setting Up Multiple Databases With Django

Working with multiple databases in Django can seem a bit overwhelming at first but setting it up properly is straight forward and really effective.  I'm working on a project where I need to set up an external read-only database running MySQL.  I don't typically use MySQL and I wanted to isolate the data that was being imported into this database.  The database …

Building a Custom Django Admin Form

I recently needed an easy way to bulk upload data to one of my database models from the Django admin.  I didn't want this functionality accessible to users so it didn't make sense to build the CSV file import into the main application.  The only other place on the app where this form could live is the Django admin (at least for now).

There is a lot that can be …

Debugging Django Management Commands with strace

This past week I ran into an issue where a django management command running on a cron began to hang.   I began to rollback changes to the environment, downgrading python versions, downgrading postgresql versions and even rebuilding the application in another region on Digial Ocean.  None of this seemed to work.  My initial hypothisis was that there was a bug in the managem…

Django Constraints

As of Django 2.2, you can add database constraints to your models.  I find database constraints extremely valuable and one of those few features that Django really needed.

This blog post is more of a quick reference for myself when adding constraints to my Django models

Django has support for both CheckConstraints and UniqueConstraints.&n…

Term-centric search using Elasticsearch and Django

Recently I've been working on a side project that has a search component at it's core. I'm pulling a set of data from an external source, loading it into my database and pushing the data to Elasticsearch. There are a handful of fields that I need to search over and I wanted to do a google style search (single search bar) rather than a faceted search. This means I have to search for…