In this tutorial, we've shown you how to configure P圜harm for debugging a Django app running inside of Docker. 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. We can now see the Run/Debug configuration at the top of the P圜harm window and that the buttons (for run, debug, etc.) are enabled. The important thing in this configuration dialog is to set the "Host" field to 0.0.0.0.Ĭlick "OK" to save the configuration. Next click the "+" button and choose "Django server". Now that we've configured P圜harm 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.Ĭlick on the "Add configuration." button at the top of the P圜harm window. All other services in your Docker Compose file will start when we later run the configuration in P圜harmīack in the "Python Interpreter" setting dialog you should now see that the project has the correct remote interpreter.Ĭlose the settings. The debugger attaches specifically to the web service. env.dev depends_on : - db db : image : postgres:12.0-alpine volumes : - postgres_data:/var/lib/postgresql/data/ environment : - POSTGRES_USER=hello_django - POSTGRES_PASSWORD=hello_django - POSTGRES_DB=hello_django_dev volumes : postgres_data :
app/:/usr/src/app/ ports : - 8008:8000 env_file : -. Upload your code to PythonAnywhere Set up a virtualenv and install Django and any other requirements Set up your web app using the manual config option.
app command : python manage.py runserver 0.0.0.0:8000 volumes :. 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.įor example, if your Docker Compose file looks like this, then you'll want to point to the web service: 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. Assuming you have a project open, open the settings once again and expand the "Project: " setting and click "Python Interpreter". For this, on the top right corner of Pycharm, you need.
Now that we have the Docker configuration set up, it's time to configure Docker Compose as a remote interpreter. In case you wanna run the entire test suit, you need to create a test configuration.
Click "Docker" and then click the "+" button to create a new Docker configuration.įor Mac, select the Docker for Mac options. To do so, open P圜harm settings ( P圜harm > Preferences for Mac users or File > Settings for Windows and Linux users), and then expand the "Build, Execution, Deployment" setting. The first step we need to do is to tell P圜harm how to connect to Docker.