[3.0.x] Clarified AppConfig.ready() docs example.
Backport of 971a84d6af
from master
This commit is contained in:
parent
a56e45a2bf
commit
ef22cf41af
|
@ -256,15 +256,20 @@ Methods
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
|
from django.apps import AppConfig
|
||||||
from django.db.models.signals import pre_save
|
from django.db.models.signals import pre_save
|
||||||
|
|
||||||
def ready(self):
|
|
||||||
# importing model classes
|
|
||||||
from .models import MyModel # or...
|
|
||||||
MyModel = self.get_model('MyModel')
|
|
||||||
|
|
||||||
# registering signals with the model's string label
|
class RockNRollConfig(AppConfig):
|
||||||
pre_save.connect(receiver, sender='app_label.MyModel')
|
# ...
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
# importing model classes
|
||||||
|
from .models import MyModel # or...
|
||||||
|
MyModel = self.get_model('MyModel')
|
||||||
|
|
||||||
|
# registering signals with the model's string label
|
||||||
|
pre_save.connect(receiver, sender='app_label.MyModel')
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue