mirror of
https://github.com/django/django.git
synced 2025-02-25 01:25:34 +00:00
Clarified AppConfig.ready() docs example.
This commit is contained in:
parent
486a8dae2d
commit
971a84d6af
@ -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…
x
Reference in New Issue
Block a user