1
# -*- coding: utf-8 -*-
1
2
from __future__ import unicode_literals
4
from django.core.checks.compatibility.base import check_compatibility
5
from django.core.management.base import NoArgsCommand
8
class Command(NoArgsCommand):
9
help = "Checks your configuration's compatibility with this version " + \
12
def handle_noargs(self, **options):
13
for message in check_compatibility():
14
warnings.warn(message)
4
from optparse import make_option
6
from django.apps import apps
7
from django.core import checks
8
from django.core.checks.registry import registry
9
from django.core.management.base import BaseCommand, CommandError
12
class Command(BaseCommand):
13
help = "Checks the entire Django project for potential problems."
15
requires_system_checks = False
17
option_list = BaseCommand.option_list + (
18
make_option('--tag', '-t', action='append', dest='tags',
19
help='Run only checks labeled with given tag.'),
20
make_option('--list-tags', action='store_true', dest='list_tags',
21
help='List available tags.'),
24
def handle(self, *app_labels, **options):
25
if options.get('list_tags'):
26
self.stdout.write('\n'.join(sorted(registry.tags_available())))
30
app_configs = [apps.get_app_config(app_label) for app_label in app_labels]
34
tags = options.get('tags', None)
35
if tags and any(not checks.tag_exists(tag) for tag in tags):
36
invalid_tag = next(tag for tag in tags if not checks.tag_exists(tag))
37
raise CommandError('There is no system check with the "%s" tag.' % invalid_tag)
39
self.check(app_configs=app_configs, tags=tags, display_num_errors=True)