Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Add apps.py to run autodiscover automatically in recent django.
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Nov 12, 2016
1 parent 6465049 commit 099f8e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/permission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from permission.conf import settings
from django.core.exceptions import ImproperlyConfigured


if 'permission' in settings.INSTALLED_APPS:
if settings.PERMISSION_CHECK_AUTHENTICATION_BACKENDS:
if ('permission.backends.PermissionBackend' not in
Expand Down Expand Up @@ -48,3 +49,6 @@ def has_permissionif_in_builtins():
'Users can ignore this exception via setting `False` to '
'`PERMISSION_CHECK_TEMPLATES_OPTIONS_BUILTINS`.'
)

# Django Application
default_app_config = 'permission.apps.PermissionConfig'
12 changes: 12 additions & 0 deletions src/permission/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.apps import AppConfig


class PermissionConfig(AppConfig):
name = "permission"
verbose_name = "Permission"

def ready(self):
from permission.conf import settings
if settings.PERMISSION_AUTODISCOVER_ENABLE:
from permission.utils.autodiscover import autodiscover
autodiscover()
1 change: 1 addition & 0 deletions src/permission/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PermissionConf(AppConf):

AUTODISCOVER_MODULE_NAME = 'perms'
AUTODISCOVER_VARIABLE_NAME = 'PERMISSION_LOGICS'
AUTODISCOVER_ENABLE = True

CHECK_AUTHENTICATION_BACKENDS = True
"""Check if AUTHENTICATION_BACKENDS is correctly configured"""
Expand Down

0 comments on commit 099f8e5

Please sign in to comment.