Loading django/core/checks/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ from .registry import Tags, register, run_checks, tag_exists # Import these to force registration of checks import django.core.checks.caches # NOQA isort:skip import django.core.checks.compatibility.django_1_8_0 # NOQA isort:skip import django.core.checks.database # NOQA isort:skip import django.core.checks.model_checks # NOQA isort:skip import django.core.checks.security.base # NOQA isort:skip import django.core.checks.security.csrf # NOQA isort:skip Loading django/core/checks/database.py 0 → 100644 +11 −0 Original line number Diff line number Diff line from django.db import connections from . import Tags, register @register(Tags.database) def check_database_backends(*args, **kwargs): issues = [] for conn in connections.all(): issues.extend(conn.validation.check(**kwargs)) return issues django/core/checks/registry.py +6 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Tags(object): admin = 'admin' caches = 'caches' compatibility = 'compatibility' database = 'database' models = 'models' security = 'security' signals = 'signals' Loading Loading @@ -70,6 +71,11 @@ class CheckRegistry(object): if tags is not None: checks = [check for check in checks if hasattr(check, 'tags') and set(check.tags) & set(tags)] else: # By default, 'database'-tagged checks are not run as they do more # than mere static code analysis. checks = [check for check in checks if not hasattr(check, 'tags') or Tags.database not in check.tags] for check in checks: new_errors = check(app_configs=app_configs) Loading django/core/management/base.py +4 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,9 @@ class BaseCommand(object): translation.activate(saved_locale) return output def _run_checks(self, **kwargs): return checks.run_checks(**kwargs) def check(self, app_configs=None, tags=None, display_num_errors=False, include_deployment_checks=False, fail_level=checks.ERROR): """ Loading @@ -376,7 +379,7 @@ class BaseCommand(object): If there are only light messages (like warnings), they are printed to stderr and no exception is raised. """ all_issues = checks.run_checks( all_issues = self._run_checks( app_configs=app_configs, tags=tags, include_deployment_checks=include_deployment_checks, Loading django/core/management/commands/migrate.py +6 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from collections import OrderedDict from importlib import import_module from django.apps import apps from django.core.checks import Tags, run_checks from django.core.management.base import BaseCommand, CommandError from django.core.management.sql import ( emit_post_migrate_signal, emit_pre_migrate_signal, Loading Loading @@ -56,6 +57,11 @@ class Command(BaseCommand): help='Creates tables for apps without migrations.', ) def _run_checks(self, **kwargs): issues = run_checks(tags=[Tags.database]) issues.extend(super(Command, self).check(**kwargs)) return issues def handle(self, *args, **options): self.verbosity = options['verbosity'] Loading Loading
django/core/checks/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ from .registry import Tags, register, run_checks, tag_exists # Import these to force registration of checks import django.core.checks.caches # NOQA isort:skip import django.core.checks.compatibility.django_1_8_0 # NOQA isort:skip import django.core.checks.database # NOQA isort:skip import django.core.checks.model_checks # NOQA isort:skip import django.core.checks.security.base # NOQA isort:skip import django.core.checks.security.csrf # NOQA isort:skip Loading
django/core/checks/database.py 0 → 100644 +11 −0 Original line number Diff line number Diff line from django.db import connections from . import Tags, register @register(Tags.database) def check_database_backends(*args, **kwargs): issues = [] for conn in connections.all(): issues.extend(conn.validation.check(**kwargs)) return issues
django/core/checks/registry.py +6 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ class Tags(object): admin = 'admin' caches = 'caches' compatibility = 'compatibility' database = 'database' models = 'models' security = 'security' signals = 'signals' Loading Loading @@ -70,6 +71,11 @@ class CheckRegistry(object): if tags is not None: checks = [check for check in checks if hasattr(check, 'tags') and set(check.tags) & set(tags)] else: # By default, 'database'-tagged checks are not run as they do more # than mere static code analysis. checks = [check for check in checks if not hasattr(check, 'tags') or Tags.database not in check.tags] for check in checks: new_errors = check(app_configs=app_configs) Loading
django/core/management/base.py +4 −1 Original line number Diff line number Diff line Loading @@ -368,6 +368,9 @@ class BaseCommand(object): translation.activate(saved_locale) return output def _run_checks(self, **kwargs): return checks.run_checks(**kwargs) def check(self, app_configs=None, tags=None, display_num_errors=False, include_deployment_checks=False, fail_level=checks.ERROR): """ Loading @@ -376,7 +379,7 @@ class BaseCommand(object): If there are only light messages (like warnings), they are printed to stderr and no exception is raised. """ all_issues = checks.run_checks( all_issues = self._run_checks( app_configs=app_configs, tags=tags, include_deployment_checks=include_deployment_checks, Loading
django/core/management/commands/migrate.py +6 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ from collections import OrderedDict from importlib import import_module from django.apps import apps from django.core.checks import Tags, run_checks from django.core.management.base import BaseCommand, CommandError from django.core.management.sql import ( emit_post_migrate_signal, emit_pre_migrate_signal, Loading Loading @@ -56,6 +57,11 @@ class Command(BaseCommand): help='Creates tables for apps without migrations.', ) def _run_checks(self, **kwargs): issues = run_checks(tags=[Tags.database]) issues.extend(super(Command, self).check(**kwargs)) return issues def handle(self, *args, **options): self.verbosity = options['verbosity'] Loading