Django Debugging

Does anybody managed to debug a django application? Can I see some errors logs of the environment to see why the debugger fails?

Check this out

Setting up Django is quite easy (first example on the page). Debugging a simple python app (last example on the page) is also working. But debugging a Django app is not working on my workspace. Is theres an example of a working debugger configuration for a Django app or can I see some logs why the startup fails?

1 Like

Do you have a specific app you’d like to debug?

Maybe we could set up debugging in Gitpod’s Django application example? https://github.com/gitpod-io/django-locallibrary-tutorial

It’s currently featured in Gitpod’s example repos when you have no workspaces.

Hi, just coming back, the debugging is working, you can add this launch.json file to your example project if you like:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Django",
      "type": "python",
      "request": "launch",
      "program": "${workspaceFolder}/manage.py",
      "args": [
        "runserver",
        "--noreload",
        "--settings=locallibrary.local_settings"
      ],
      "django": true
    }
  ]
}
1 Like

@mrussmann that’s awesome, many thanks for sharing your config! :100:

I’ll add it to the python-in-gitpod section of the docs as a external resource thank you @mrussmann!

Would be nice to also check it into the django example. However, it did not work for me when I tried.

Hi, I made a quick demo and forked your fork :). It contains some small changes to demonstrate the debug configuration: I added a settings file which tells Theia the right python version, added a launch.json with sets the used port to 8080 (like in your example) added the local-settings variable to the bash.rc (in gitpod.yml) so it gets not lost when opening a new terminal, I think thats all:

1 Like

I just added pylint-django to requirements.txt and activated the module in the settings.json to get rid of some error messages.