<< All Blog Posts
Kick Start your Django/Plone Buildout with PyCharm

Kick Start your Django/Plone Buildout with PyCharm

Update (Dec. 1, 2021): The last version of PyCharm with support for Buildout was 2021.2.

If you use Buildout for Django projects, or if you are a Plone developer, I have great news for you: PyCharm Professional Edition has built-in Buildout support. PyCharm has great features, such as a Debugger, code completion, syntax highlighting and code formatting for Buildout configuration files. Unfortunately, getting started is a bit difficult since Buildout doesn't install the eggs into a standard place like a virtualenv would and because the docs can be unclear regarding how to get this actually hooked up and working.

Here are a few tips to kick start your Django/Plone Buildout so that PyCharm recognizes the eggs in your configuration:

Making PyCharm Aware of Your Eggs

Depending on the layout of your project, PyCharm may not recognize that you are actually using Buildout. For example, I typically install zc.buildout and setuptools into a virtualenv inside of my project so I can skip the bootstrap.py method of installing buildout. Make sure PyCharm has enabled support for Buildout in your project by going to the PyCharm settings pane and checking the box.

PyCharm Buildout Settings

You will also need to specify a script that has the Python paths in it to your eggs. You will have to at least run Buildout once and select one of the generated scripts in the ${buildout:directory}/bin that contains paths to all of the eggs used in your project. The PyCharm docs will tell you to choose the ${buildout:directory}/bin/buildout script, but it may not have all of your eggs.

In my Plone based projects, I will typically have a ${buildout:directory}/bin/zopepy script that has everything ready to go.

Just put in the path to that script and now you can code complete modules from your project.

PyCharm Configured

Using the PyCharm Debugger with Django

Using the PyCharm Debugger with your Django project is easy because under the "Run" menu, there is a pre-built Django server configuration ready to use.

Using the PyCharm Debugger with Plone

If you have ever used pdb with Plone, you know it is about the only way you can figure out what is happening inside the large stack of code and calls that make up the CMS. Fortunately, PyCharm has an amazing debugger feature that can unlock even more of the secrets of the stack and in a very pretty and usable way.

To get started using the PyCharm debugger, you will need to configure PyCharm to run your project.

Under the "Run" menu in PyCharm, you can "Edit Configurations...". This will open up the dialog so you can add a Run/Debug Configuration. Now you can edit it to start the Plone ${buildout:directory}/bin/instance command passing it the fg argument. If your project interpreter is setup correctly, it should be already selected. After that, you can set the "Working Directory" to be the ${buildout:directory}.

PyCharm Plone Run Configuration

I recommend checking the box for "Single Instance only" so as to quickly switch between running and debugging modes in PyCharm. Now you can add breakpoints via PyCharm’s UI so that Plone stops and lets you inspect the current stack and all of the variable. PyCharm Debugger One last tip: if you want to speed up debugging in PyCharm, make sure to compile the Cython extensions when presented with the option. Enjoy!

Strategy Guide Photo

Save Time With Django Strategy Guides

Save time in your Django development projects: download our free strategy guides on Django Filters and Django Tag Templates.

Thanks for filling out the form! A Six Feet Up representative will be in contact with you soon.

Connect with us