|
26 | 26 | READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False) |
27 | 27 |
|
28 | 28 | if READ_DOT_ENV_FILE: |
29 | | - # Operating System Environment variables have precedence over variables defined in the .env file, |
| 29 | + # Operating System Environment variables have precedence over variables defined in the |
| 30 | + # .env file, |
30 | 31 | # that is to say variables from the .env files will only be used if not defined |
31 | 32 | # as environment variables. |
32 | 33 | env_file = str(ROOT_DIR / ".env") |
|
322 | 323 | "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", |
323 | 324 | } |
324 | 325 |
|
325 | | -# By Default swagger ui is available only to admin user(s). You can change permission classes to change that |
| 326 | +# By Default swagger ui is available only to admin user(s). You can change permission |
| 327 | +# classes to change that |
326 | 328 | # See more configuration options at https://drf-spectacular.readthedocs.io/en/latest/settings.html#settings |
327 | 329 | SPECTACULAR_SETTINGS = { |
328 | 330 | "TITLE": "fpbase API", |
@@ -464,17 +466,18 @@ def add_sentry_context(logger, method_name, event_dict): |
464 | 466 | using the ID to find the full exception context in Sentry. |
465 | 467 | """ |
466 | 468 | # Check if sentry_event_id was explicitly passed in extra dict |
467 | | - if "sentry_event_id" not in event_dict: |
468 | | - # Try to get it from Sentry SDK's last_event_id() |
469 | | - # This works if Django/Sentry integration auto-captured an exception |
470 | | - if event_dict.get("exc_info") or "exception" in event_dict: |
471 | | - try: |
472 | | - import sentry_sdk |
473 | | - |
474 | | - if event_id := sentry_sdk.last_event_id(): |
475 | | - event_dict["sentry_event_id"] = event_id |
476 | | - except (ImportError, AttributeError, Exception): |
477 | | - pass # Sentry not available |
| 469 | + # Try to get it from Sentry SDK's last_event_id() |
| 470 | + # This works if Django/Sentry integration auto-captured an exception |
| 471 | + if "sentry_event_id" not in event_dict and ( |
| 472 | + event_dict.get("exc_info") or "exception" in event_dict |
| 473 | + ): |
| 474 | + try: |
| 475 | + import sentry_sdk |
| 476 | + |
| 477 | + if event_id := sentry_sdk.last_event_id(): |
| 478 | + event_dict["sentry_event_id"] = event_id |
| 479 | + except (ImportError, AttributeError, Exception): |
| 480 | + pass # Sentry not available |
478 | 481 |
|
479 | 482 | return event_dict |
480 | 483 |
|
|
0 commit comments