$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[DJUGL] Signals and AppConfig
Search
Ana Balica
October 06, 2015
Programming
0
340
[DJUGL] Signals and AppConfig
Django User Group in London meetup and my talk about "Signals and AppConfig" Rick and Morty style!
Ana Balica
October 06, 2015
Tweet
Share
More Decks by Ana Balica
See All by Ana Balica
[NDC London] HTTP: History & Performance
anabalica
0
620
[DjangoCon US] Testing in Django
anabalica
1
1.4k
HTTP: History & Performance
anabalica
1
590
[DUTH] Testing in Django
anabalica
4
9.7k
[PyCon US 2016] To mock or not to mock, that is the question
anabalica
0
350
[DjangoCon Europe 2016] To mock or not to mock, that is the question
anabalica
0
490
[PyLadies London 2015] How to write a good commit message
anabalica
0
420
[EuroPython 2015] Demystifying Mixins with Django
anabalica
0
390
[DjangoCon Europe 2015] Demystifying Mixins with Django
anabalica
0
350
Other Decks in Programming
See All in Programming
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
120
Building AI Agents with TypeScript #TSKaigiHokuriku
izumin5210
6
1.3k
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
380
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
140
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
230
JETLS.jl ─ A New Language Server for Julia
abap34
1
200
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
160
CSC509 Lecture 14
javiergs
PRO
0
220
tparseでgo testの出力を見やすくする
utgwkk
1
190
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
1
920
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
160
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
140
Featured
See All Featured
Speed Design
sergeychernyshev
33
1.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
93
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
Fireside Chat
paigeccino
41
3.7k
How to Ace a Technical Interview
jacobian
280
24k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Done Done
chrislema
186
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Typedesign – Prime Four
hannesfritz
42
2.9k
Docker and Python
trallard
47
3.7k
Transcript
SIGNALS AND APPCONFIG DJUGL October 6, 2015
@anabalica
Let’s get schwifty with !
from django.db.models.signals import post_save from django.dispatch import receiver from myapp.models
import MyModel @receiver(post_save, sender=MyModel) def my_handler(sender, **kwargs): pass # my_app/signals.py
from django.db.models.signals import pre_save from django.dispatch import receiver from myapp.models
import MyModel @receiver(pre_save, sender=MyModel) def my_handler(sender, **kwargs): pass # my_app/signals.py
Django<1.7? make sure that the module it’s in gets imported
early on so that the signal handling gets registered before any signals need to be sent
Django<1.7? make sure that the module it’s in gets imported
early on so that the signal handling gets registered before any signals need to be sent
Django<1.7? this makes your app’s models.py a good place to
put registration of signal handlers
from django.db import models from my_app import signals class MyModel(models.Model):
pass # my_app/models.py
None
CIRCULAR IMPORTS
from my_app import signals # my_app/__init__.py
None
AppConfig to the rescue
AppConfig is a registry of installed apps and available models
>>> from django.apps import apps >>> apps.get_app_config('admin').verbose_name 'Admin'
from django.apps import AppConfig class RickNMortyConfig(AppConfig): name = "rick_n_morty" verbose_name
= "Rick and Morty" # my_app/apps.py
INSTALLED_APPS = [ "my_app.apps.RickNMortyConfig", # ... ] # settings.py or
default_app_config = "my_app.apps.RickNMortyConfig" # my_app/__init__.py
None
from django.apps import AppConfig class RickNMortyConfig(AppConfig): name = "rick_n_morty" verbose_name
= "Rick and Morty” def ready(self): from my_app import signals # my_app/apps.py
• Loads the settings • Sets up logging • Initializes
the application registry
• Imports each item from INSTALLED_APPS • Imports the models
submodule if exists • Runs the ready() method of each app config
None