| 2463 | |
| 2464 | @classmethod |
| 2465 | def _check_related_fields(cls): |
| 2466 | has_db_variant = False |
| 2467 | has_python_variant = False |
| 2468 | for rel in cls._meta.get_fields(): |
| 2469 | if rel.related_model: |
| 2470 | if not (on_delete := getattr(rel.remote_field, "on_delete", None)): |
| 2471 | continue |
| 2472 | if isinstance(on_delete, DatabaseOnDelete): |
| 2473 | has_db_variant = True |
| 2474 | elif on_delete != DO_NOTHING: |
| 2475 | has_python_variant = True |
| 2476 | if has_db_variant and has_python_variant: |
| 2477 | return [ |
| 2478 | checks.Error( |
| 2479 | "The model cannot have related fields with both " |
| 2480 | "database-level and Python-level on_delete variants.", |
| 2481 | obj=cls, |
| 2482 | id="models.E050", |
| 2483 | ) |
| 2484 | ] |
| 2485 | return [] |
| 2486 | |
| 2487 | @classmethod |
| 2488 | def _get_expr_references(cls, expr): |