Skip to content

Commit 489a5d3

Browse files
committed
Include signal in example project (#281)
1 parent 3acb060 commit 489a5d3

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

example/example/apps.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from django.apps import AppConfig
2+
from dynamic_preferences.signals import preference_updated
3+
4+
5+
def notify_on_preference_update(sender, section, name, old_value, new_value, **kwargs):
6+
print(
7+
"Preference {} in section {} changed from {} to {}".format(
8+
name, section, old_value, new_value
9+
)
10+
)
11+
12+
13+
class ExampleConfig(AppConfig):
14+
default_auto_field = "django.db.models.BigAutoField"
15+
name = "example"
16+
17+
def ready(self):
18+
print("Registering signals")
19+
preference_updated.connect(notify_on_preference_update)

example/example/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@
5656
"django.contrib.staticfiles",
5757
"dynamic_preferences",
5858
"dynamic_preferences.users.apps.UserPreferencesConfig",
59+
"debug_toolbar",
5960
"example",
6061
)
6162

6263
MIDDLEWARE = (
64+
"debug_toolbar.middleware.DebugToolbarMiddleware",
6365
"django.contrib.sessions.middleware.SessionMiddleware",
6466
"django.middleware.common.CommonMiddleware",
6567
"django.middleware.csrf.CsrfViewMiddleware",
@@ -68,6 +70,10 @@
6870
"django.middleware.clickjacking.XFrameOptionsMiddleware",
6971
)
7072

73+
INTERNAL_IPS = [
74+
"127.0.0.1",
75+
]
76+
7177
ROOT_URLCONF = "example.urls"
7278

7379
WSGI_APPLICATION = "example.wsgi.application"

example/example/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
# re_path(r'^blog/', include('blog.urls')),
1515
re_path(r"^admin/", admin.site.urls),
1616
re_path(r"^preferences/", include("dynamic_preferences.urls")),
17+
re_path("__debug__/", include("debug_toolbar.urls")),
1718
]

0 commit comments

Comments
 (0)