diff --git a/django/core/checks/registry.py b/django/core/checks/registry.py
index 21efbf3..18487cd 100644
a
|
b
|
class CheckRegistry(object):
|
54 | 54 | return errors |
55 | 55 | |
56 | 56 | def tag_exists(self, tag): |
57 | | tags = chain(*[check.tags for check in self.registered_checks if hasattr(check, 'tags')]) |
58 | | return tag in tags |
| 57 | return tag in self.tags_available() |
| 58 | |
| 59 | def tags_available(self): |
| 60 | return chain(*[check.tags for check in self.registered_checks if hasattr(check, 'tags')]) |
59 | 61 | |
60 | 62 | |
61 | 63 | registry = CheckRegistry() |
diff --git a/django/core/management/commands/check.py b/django/core/management/commands/check.py
index b6d2571..b0587f9 100644
a
|
b
|
from optparse import make_option
|
5 | 5 | |
6 | 6 | from django.apps import apps |
7 | 7 | from django.core import checks |
| 8 | from django.core.checks.registry import registry |
8 | 9 | from django.core.management.base import BaseCommand, CommandError |
9 | 10 | |
10 | 11 | |
… |
… |
class Command(BaseCommand):
|
16 | 17 | option_list = BaseCommand.option_list + ( |
17 | 18 | make_option('--tag', '-t', action='append', dest='tags', |
18 | 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.'), |
19 | 22 | ) |
20 | 23 | |
21 | 24 | def handle(self, *app_labels, **options): |
| 25 | if options.get('list_tags', False): |
| 26 | self.stdout.write('\n'.join(registry.tags_available())) |
| 27 | return |
| 28 | |
22 | 29 | if app_labels: |
23 | 30 | app_configs = [apps.get_app_config(app_label) for app_label in app_labels] |
24 | 31 | else: |
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 4571c24..6008338 100644
a
|
b
|
to perform only security and compatibility checks, you would run::
|
126 | 126 | |
127 | 127 | python manage.py check --tag security --tag compatibility |
128 | 128 | |
| 129 | .. django-admin-option:: --list-tags |
| 130 | |
| 131 | List all available tags. |
| 132 | |
129 | 133 | compilemessages |
130 | 134 | --------------- |
131 | 135 | |
diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py
index c770ee5..af407f5 100644
a
|
b
|
class CheckCommandTests(TestCase):
|
194 | 194 | def test_invalid_tag(self): |
195 | 195 | self.assertRaises(CommandError, call_command, 'check', tags=['missingtag']) |
196 | 196 | |
| 197 | @override_system_checks([simple_system_check]) |
| 198 | def test_list_tags_empty(self): |
| 199 | call_command('check', list_tags=True) |
| 200 | self.assertEqual('\n', sys.stdout.getvalue()) |
| 201 | |
| 202 | @override_system_checks([tagged_system_check]) |
| 203 | def test_list_tags(self): |
| 204 | call_command('check', list_tags=True) |
| 205 | self.assertEqual('simpletag\n', sys.stdout.getvalue()) |
| 206 | |
197 | 207 | |
198 | 208 | def custom_error_system_check(app_configs, **kwargs): |
199 | 209 | return [ |