Настройки отладки игнорируются, когда я перемещаю свой проект django в docker compose

we have a Django application. Right now we run it using Ubuntu 18.04 on Vagrant. Everything works fine. Now we have decided to move to docker compose. We have set everything and all is great and running. The only problem is that we have a very weird bug with the debug value.

Так, у нас есть DEBUG=True в нашем файле настроек. Мы передаем это значение в шаблон конфигурации, чтобы использовать come includes в html. Для этого у нас есть следующие настройки:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
            # Always use forward slashes, even on Windows.
            os.path.join(PROJECT_DIR, 'templates'),
        ],
        'OPTIONS': {
            'debug': DEBUG,
            'loaders': [
                # List of callables that know how to import templates from various sources.
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader',
            ],
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.request',
                'leads.context_processors.leads',
            ]
        }
    },
]

As you can see, we declare the option debug with the value of DEBUG. I have set a breakpoint on both environments there, I can see DEBUG=True.

Сейчас начинается самое интересное, если я установлю точку останова на шаблоне django, например, на этом:

    {% if not debug %}
      <link rel="stylesheet" href="somlink" />
    {% else %}
      <link rel="stylesheet" href="somelink.css" />
    {% endif %}

Тогда мы обнаруживаем два различных поведения:

  • Vagrant app: debug, as expected, is set to True, I can see the value of debug in the debugger of Pycharm.
  • Docker compose: debug cannot be seen in the debugger (I suppose that for some reason, it's not defined).

The funny thing about this is that I have setup a breakpoint on the settings file to check if, for some reason, the DEBUG settings was being set to False in docker compose, but it's set to True!!

Я даже не знаю, как попытаться решить эту проблему, потому что не могу понять, в чем она заключается. Есть идеи? Может быть, это проблема с pycharm, и мне следует открыть с ними тикет?

Вернуться на верх