Blog / Python

How to enable 2FA in the Django admin

July 14, 2021

I remember the first time I've used 2FA (two-factor authentication) was over 12 years ago when I worked as a sysadmin/netadmin in a Windows environment.  We had to purchase this RSA appliance/server and pay separate licenses for each user in the system.

Back in those days, we also used these keyfobs with a simple screen showing the 6-digit number that automatically refreshes every x seconds.  I actually thought those were really cool and when they …

Easily convert XML data to a Python dict with xmltodict

September 1, 2019

I hate working with XML mainly because I find it difficult to read.

There's a popular Python package for parsing XML called lxml which is very flexible, but I found xmltodict much better suited and easier to use for what I needed to do.

We have a inventory management app for Shopify, EZ Inventory, and one of the features we've added recently is XML support. We have a few customers whose suppliers can only …

Dealing with datetime objects and time zones in Python 3

June 29, 2019

Working with datetime objects and time zones is one of those things I always struggle with when writing code in Python. I always have to look things up and double check the outputs (such as making sure daylight savings time was taken into account) to make sure I'm doing things correctly.

This blog post is really more of a reference for myself when making adjustments to datetime objects that involve time zones so I won't …

How to check if your Python app supports TLS 1.2

June 3, 2018

As you may have already heard, the Payment Card Industry (PCI) will be requiring everyone to use at least TLS 1.1 (1.2 is recommended) to meet their data security standard starting on June 30, 2018. Other services, such as PyPI, will be requiring only TLS 1.2 connections on the same date as well.

You need to make sure that the version of Python you're using and related packages support TLS 1.2 or a bunch …

How to use proxies with an HTTP session using the Python requests package

December 26, 2017

I was working on a client project yesterday where I needed to use a proxy to make HTTP requests with the Python requests package.

In my use case, I needed to create a session and I wanted to just specify the proxy settings in one place and use that for all requests made through that session. I didn't see how to do this in the documentation so I thought I'd share my solution here.

Here's …

Older