Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
350
[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
660
[DjangoCon US] Testing in Django
anabalica
1
1.5k
HTTP: History & Performance
anabalica
1
600
[DUTH] Testing in Django
anabalica
4
9.7k
[PyCon US 2016] To mock or not to mock, that is the question
anabalica
0
370
[DjangoCon Europe 2016] To mock or not to mock, that is the question
anabalica
0
520
[PyLadies London 2015] How to write a good commit message
anabalica
0
430
[EuroPython 2015] Demystifying Mixins with Django
anabalica
0
410
[DjangoCon Europe 2015] Demystifying Mixins with Django
anabalica
0
360
Other Decks in Programming
See All in Programming
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
3
1.6k
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
220
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
370
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
380
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
390
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
880
TipKitTips
ktcryomm
0
160
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
410
AIに任せる範囲を安全に広げるためにやっていること
fukucheee
0
130
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
370
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
170
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.7k
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing Experiences People Love
moore
143
24k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
99
A designer walks into a library…
pauljervisheath
210
24k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
The agentic SEO stack - context over prompts
schlessera
0
690
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
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