Skip to content

Write More Meaningful Time Constants

One thing that I strive to achieve is to write code that doesn't need comments to convey meaning. The most basic thing when doing this is to avoid using magic numbers. In this article, I'll illustrate how I avoid using them when it comes to time constants.

How to Set a Variable in Django Template

As you may have figured by now, Django does not implement such a feature. That is because the logic of setting the variable must go in the view, not in the template. But there are some rare cases when you need this.

Capture the Output of a Django Command

The documentation is very slim when it talks about how to call a Django command from code. To do this, just use call_command. To solve the trick of capturing the output of this I had to dig a little into the Django source.