You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在VS Code调试器中通过venv运行NetBox时--insecure参数不被识别

问题描述

在Ubuntu虚拟机的远程VS Code Server中运行NetBox,已激活venv并指定venv的Python解释器,但--insecure参数始终无法被识别。

调试配置(launch.json)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Django",
            "type": "debugpy",
            "request": "launch",
            "args": [
                "runserver",
                "0.0.0.0:8000",
                "--insecure"
            ],
            "django": true,
            "autoStartBrowser": false,
            "program": "${workspaceFolder}/netbox/manage.py"
        }
    ]
}

错误信息

运行调试器和直接在命令行执行时均抛出相同错误:

usage: manage.py runserver [-h] [--ipv6] [--nothreading] [--noreload] [--version] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--no-color] [--force-color]
                           [--skip-checks]
                           [addrport]
manage.py runserver: error: unrecognized arguments: --insecure

解决方法

原因

NetBox从v3.2版本开始,不再兼容Django原生的--insecure参数——它已经集成了独立的静态文件处理逻辑,官方推荐通过预收集静态文件的方式替代该参数的功能。

操作步骤

  1. 预收集静态文件
    激活venv后,执行以下命令将静态文件统一收集到指定目录:

    python netbox/manage.py collectstatic
    

    执行时会弹出确认提示,输入yes完成收集。

  2. 移除无效参数
    修改launch.json配置,删除--insecure参数,最终配置如下:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python Debugger: Django",
                "type": "debugpy",
                "request": "launch",
                "args": [
                    "runserver",
                    "0.0.0.0:8000"
                ],
                "django": true,
                "autoStartBrowser": false,
                "program": "${workspaceFolder}/netbox/manage.py"
            }
        ]
    }
    
  3. 重新启动服务
    现在直接运行调试器或命令行命令即可正常加载静态文件:

    python netbox/manage.py runserver 0.0.0.0:8000
    

内容的提问来源于stack exchange,提问作者Colin Lacy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 22:32:09