Autodiscover components in components.py inside an app (#24)

Co-authored-by: @danjac
This commit is contained in:
Dan Jacob 2021-02-05 22:31:09 +02:00 committed by GitHub
parent ce7906b6f4
commit 4df314b7f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import sys
from django.conf import settings
class AppSettings:
def __init__(self):
self.settings = getattr(settings, "COMPONENTS", {})
@property
def AUTODISCOVER(self):
return self.settings.setdefault("autodiscover", True)
@property
def LIBRARIES(self):
return self.settings.setdefault("libraries", [])
app_settings = AppSettings()
app_settings.__name__ = __name__
sys.modules[__name__] = app_settings