summaryrefslogtreecommitdiff
path: root/django/contrib/auth/apps.py
blob: 9d128db39cc6c093ccf685aa4ef4232698c4f445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.apps import AppConfig
from django.core import checks
from django.db.models.signals import post_migrate
from django.utils.translation import ugettext_lazy as _

from .checks import check_models_permissions, check_user_model
from .management import create_permissions


class BaseAuthConfig(AppConfig):
    """
    AppConfig which assumes that the auth models don't exist.
    """
    name = 'django.contrib.auth'
    verbose_name = _("Authentication and Authorization")

    def ready(self):
        checks.register(check_user_model, checks.Tags.models)


class AuthConfig(BaseAuthConfig):
    """
    The default AppConfig for auth.
    """

    def ready(self):
        super(AuthConfig, self).ready()
        post_migrate.connect(
            create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions"
        )
        checks.register(check_models_permissions, checks.Tags.models)