Pycharm Community Django



Community; PyCharm; PyCharm install Django failed Follow. Created March 09, 2020 10:45. I have some kind of a dumb problem with django installation. I think, Pycharm is THE best IDE for developing python. But unfortunately, the professional edition is not free. But community edition is good enough for doing debugging, integrating GIT etc. Normally its easy to use the community edition for django and tornado’s debugging/running if you know how to configure.

Latest version

Released:

App for Django to during development enter PyCharm debugger on uncaught exceptions

Pycharm Community Django

Project description

App for Django to enter PyCharm debugger on uncaught exceptions

  • Free software: BSD license

Features

  • Uncaught exceptions in django view implementations (and middlewares) will trigger the PyCharmdebugger

Installation

You can install the plugin by running

Community
pip install django-pycharm-breakpoint

In settings.py add django-pycharm-breakpoint to your INSTALLED_APPS

INTALLED_APPS += [‘django_pycharm_breakpoint’]

Usage

When running in the PyCharm debugger and the package is installed and added to the INSTALLED_APPSdjango setting, any uncaught exception will trigger a breakpoint in PyCharm.

Release historyRelease notifications | RSS feed

0.3.0

0.2.0

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-pycharm-breakpoint, version 0.3.0
Filename, sizeFile typePython versionUpload dateHashes
Filename, size django-pycharm-breakpoint-0.3.0.tar.gz (3.8 kB) File type Source Python version None Upload dateHashes

Pycharm Open Existing Django Project

Pycharm community django testClose

Hashes for django-pycharm-breakpoint-0.3.0.tar.gz

Hashes for django-pycharm-breakpoint-0.3.0.tar.gz
AlgorithmHash digest
SHA2566ee4ef63f3168a4cc9c784735f0745b545b38193bac089965728fa037efd13ba
MD5835eb77117dc28e047768959c595614b
BLAKE2-256a5a67a4e0f818914fac19ebc67dd7fc0910cbbc724076939d7c05534819824c2

Developing your Django app in Docker can be very convenient. You don't have to install extra services like Postgres, Nginx, and Redis, etc. on you own machine. It also makes it much easier for a new developer to quickly get up and running.

The grass is not always greener, though. Running Django in Docker can create some problems and make what was once easy difficult. For example, how do you set breakpoints in your code and debug?

In this quick tutorial, we'll look at how PyCharm comes to the rescue with its remote interpreter and Docker integration to make it easy to debug a containerized Django app.

This post uses PyCharm Professional Edition v2020.1.1. For the differences between the Professional and Community (free) Editions of PyCharm, take a look at the Professional vs. Community - Compare Editions guide.

Contents

Objectives

By the end of this tutorial, you should be able to do the following in PyCharm:

  1. Configure Docker settings
  2. Set up a Remote Interpreter
  3. Create a Run/Debug configuration to debug a Django app running inside of Docker

Docker Settings in PyCharm

The first step we need to do is to tell PyCharm how to connect to Docker. To do so, open PyCharm settings (PyCharm > Preferences for Mac users or File > Settings for Windows and Linux users), and then expand the 'Build, Execution, Deployment' setting. Click 'Docker' and then click the '+' button to create a new Docker configuration.

For Mac, select the Docker for Mac options. Then apply the changes.

Setup a Remote Interpreter

Now that we have the Docker configuration set up, it's time to configure Docker Compose as a remote interpreter. Assuming you have a project open, open the settings once again and expand the 'Project <your-project-name>' setting and click 'Project Interpreter'. Click the gear icon and choose 'Add'.

In the next dialog, choose 'Docker Compose' in the left pane, and select the Docker configuration you created in the previous steps in the 'Server' field. The 'Configuration file(s)' field should point to your Docker Compose file while the 'Service' field should point to the web application service from your Docker Compose file.

For example, if your Docker Compose file looks like this, then you'll want to point to the web service:

The debugger attaches specifically to the web service. All other services in your Docker Compose file will start when we later run the configuration in PyCharm

Click 'OK' to apply the changes.

Back in the 'Project Interpreter' setting dialog you should now see that the project has a remote interpreter.

Close the settings.

Create a Run/Debug Configuration

Now that we've configured PyCharm to be able to connect to Docker and created a remote interpreter configuration based on the Docker Compose file, we can create a Run/Debug configuration.

Click on the 'Add configuration...' button at the top of the PyCharm window.

Next click the '+' button and choose 'Django server'.

Give the configuration a name. The important thing in this configuration dialog is to set the 'Host' field to 0.0.0.0.

Click 'OK' to save the configuration. We can now see the Run/Debug configuration at the top of the PyCharm window and that the buttons (for run, debug, etc.) are enabled.

If you now set breakpoints in your Django app and press the debug button next to the Run/Debug configuration, you can debug the Django app running inside the Docker container.

Conclusion

Django

In this tutorial, we've shown you how to configure PyCharm for debugging a Django app running inside of Docker. With that, you can now not only debug your views and models and what not, but also set breakpoints and debug your template code.

TIP: Want to supercharge your debugging even more? PyCharm also lets you set conditional breakpoints!