I work for Mozilla, and we’re working on an internal tool to help us manage our repository (tree) tests. We use a Vagrant environment to run the service (back-end) portion and the front-end is written in Angular.js. The project is called Treeherder.
I love using PyCharm, and love the debugger, and wanted to debug some code on the service. I ran into a few hiccups with it, but now have it working. Here’s how I did it.
Firstly, credit where credit is due:
- This was the first post I used to get going. An excellent starting place.
- And, of course, the docs helped a bit
- And help from my friend at Mozilla, Ed Morley. He mentioned that I needed to manually enter the environment variables that we have set in the vagrant env at
/etc/profile.d/treeherder.shlike this:
After those things, my configuration looked like this:
and my environment variables (which were a bit of a pain to add manually) looked like this:
then for Vagrant setup:
and the remote interpreter:
PyCharm Django settings:
Things I ran into
I was getting an error where it couldn’t find ROOT_URLCONF when running. After adding that to the settings file, it was able to run. But then I was getting InvalidCacheBackendError.
The issue ended up being that we have a base.py settings file, and then each user has a local.py settings file which extends it. The “extending” didn’t seem to work. So I made a new copy of the file called pycharm_django_settings.py in the same folder. This file was just a copy of all the base.py settings and the local.py settings. There may be a better way to do this, but this worked for me.
After creating that file, I had to set this for the PyCharm properties | django settings for that project to point to that new file. But I ALSO had to set the DJANGO_SETTINGS_MODULE value above to point to that file.
After that, I was able to run our service in PyCharm and could start debugging!




