Skip to content

Visual Studio Code debugging implementation in manage.py causes error #101

@Schwankenson

Description

@Schwankenson

I configured django single step debugging for Visual Studio Code with this tutorial:

https://gist.github.com/veuncent/1e7fcfe891883dfc52516443a008cfcb

The code

from django.conf import settings

if settings.DEBUG:
    if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
        import ptvsd
        ptvsd.enable_attach(address = ('0.0.0.0', 8005))
        print("Attached remote debugger")

Caused an error in my application, because the django.conf.settings object was not available in one of my subapps.

I changed the code to

if os.environ.get('RG_START_PTVSD_DEBUGGER'):
    if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
        import ptvsd
        ptvsd.enable_attach(address = ('0.0.0.0', 8005))
        print("Attached remote debugger")

And everything worked fine.

The error was only in the sslserver, not in django runserver itself

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions