相关疑难解决方法(0)

如何判断我的Django应用程序是否在开发服务器上运行?

我怎样才能确定我的应用程序是否在开发服务器上运行?我想,我可以检查的价值settings.DEBUG,并假设如果DEBUGTrue那么它的开发服务器上运行,但我更愿意知道肯定不是依靠惯例.

python django wsgi

51
推荐指数
5
解决办法
2万
查看次数

如何防止哨兵在 Django 本地服务器上记录错误?

当我在本地服务器上工作时(即http://127.0.0.1:8000/ ) ,我试图阻止 Sentry 将错误记录到我的 Sentry 仪表板。我希望哨兵将错误记录到仪表板的唯一时间是当我的代码投入生产时。我该怎么办?我在下面尝试过这个,但它不起作用:

if DEBUG == True
    sentry_sdk.init(
        dsn=os.environ.get('SENTRY_DSN', None),
        integrations=[DjangoIntegration()],
    
        # Set traces_sample_rate to 1.0 to capture 100%
        # of transactions for performance monitoring.
        # We recommend adjusting this value in production.
        traces_sample_rate=1.0,
    
        # If you wish to associate users to errors (assuming you are using
        # django.contrib.auth) you may enable sending PII data.
        send_default_pii=True
    )
Run Code Online (Sandbox Code Playgroud)

python django django-settings sentry

0
推荐指数
1
解决办法
1825
查看次数

标签 统计

django ×2

python ×2

django-settings ×1

sentry ×1

wsgi ×1