45 lines
1.8 KiB
Diff
45 lines
1.8 KiB
Diff
Now I have a good understanding of the fix. Let me provide a cleaner, more properly formatted patch for this Django issue:
|
|
|
|
--- a/django/core/checks/model_checks.py
|
|
+++ b/django/core/checks/model_checks.py
|
|
@@ -4,7 +4,8 @@ import operator
|
|
from itertools import chain
|
|
|
|
from django.apps import apps
|
|
-from django.core.checks import Error, Tags, register
|
|
+from django.conf import settings
|
|
+from django.core.checks import Error, Tags, Warning, register
|
|
|
|
|
|
@register(Tags.models)
|
|
@@ -35,12 +36,23 @@ def check_all_models(app_configs=None, **kwargs):
|
|
for db_table, model_labels in db_table_models.items():
|
|
if len(model_labels) != 1:
|
|
- errors.append(
|
|
- Error(
|
|
- "db_table '%s' is used by multiple models: %s."
|
|
- % (db_table, ', '.join(db_table_models[db_table])),
|
|
- id='models.E028',
|
|
+ model_labels_str = ', '.join(db_table_models[db_table])
|
|
+ if settings.DATABASE_ROUTERS:
|
|
+ errors.append(
|
|
+ Warning(
|
|
+ "db_table '%s' is used by multiple models: %s."
|
|
+ % (db_table, model_labels_str),
|
|
+ hint=(
|
|
+ "You have configured settings.DATABASE_ROUTERS. Verify "
|
|
+ "that %s are correctly routed to separate databases."
|
|
+ ) % model_labels_str,
|
|
+ id='models.W035',
|
|
+ )
|
|
)
|
|
- )
|
|
+ else:
|
|
+ errors.append(
|
|
+ Error(
|
|
+ "db_table '%s' is used by multiple models: %s."
|
|
+ % (db_table, model_labels_str),
|
|
+ id='models.E028',
|
|
+ )
|
|
+ )
|
|
return errors
|