Personal tools

Contact Us 24/7 > 1 866.SIX FEET

Skip to content. | Skip to navigation

Home > Blog > Kick Start your Django/Plone Buildout with PyCharm


Banner image

Kick Start your Django/Plone Buildout with PyCharm

written by Calvin Hendryx-Parker on Saturday August 5, 2017

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 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.

PyCharm Add 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.


Posted by Fred van Dijk on Aug 07, 2017 05:39 AM
Hi Calvin, thank you very much for the thorough blog post on your pycharm setup. Two questions: do you still have omelette in your buildout, generating the symlinked module namespace under parts/omelette ? did you change anything in the Project Structure preferences for certain folders in your buildout? For me it was common sense to exclude parts en var.
Posted by calvin on Aug 07, 2017 01:18 PM
* I do still have the Omlette linked in, but that is just because I have my egg cache outside of my workspace. * I hadn't been ignoring those directories, but I think I will ignore anything that isn't checked into source control management. This biggest speedup to indexing on a project recently was to not index `blobstorage` but I already have PyCharm configured to ignore any directory with that name. I do not notice that I have the same issue with `zope.interface` imports. They are showing as an *Unresolved reference* in the editor. I just downloaded and tried with the latest 2017.2 RC so it doesn't appear to be fixed.
Add comment

You can add a comment by filling out the form below. Plain text formatting.


Next Steps

Select a type of support:

Contact our sales team

First name:
Last name:
Phone Number:
Fight spam:
What is + ?
Call Us 1 866.SIX FEET