Env vars with Python and Django: environ vs django-environ

One of the struggles when learning new languages and tech stacks is knowing if you’re doing ‘the right thing’ because you don’t know enough yet to know any better. I’m working on a personal Django project and need to externalize some properties, so I need to read some environment variables.

I was following this article but instead of adding a dependency for ‘django-environ’ I somehow miscopied and pasted ‘environ’, which initially didn’t give any errors until I tried to run my app, and ran into this unintelligible error:

raise ValueError, "No frame marked with %s." % fname
SyntaxError: invalid syntax

I’m not too sure at this point what this means, but a quick Google found this article which luckily points out that ‘environ’ is for Python 2 and I shouldn’t be using that.

‘django-python’ apparently also needs a later python version than I’m using, so changing to python-environ and I’m up and running.