Browse Source

Clarified AppConfig.ready() docs example.

Adam Johnson 5 years ago
parent
commit
971a84d6af
1 changed files with 11 additions and 6 deletions
  1. 11 6
      docs/ref/applications.txt

+ 11 - 6
docs/ref/applications.txt

@@ -256,15 +256,20 @@ Methods
 
     Example::
 
+        from django.apps import AppConfig
         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
-            pre_save.connect(receiver, sender='app_label.MyModel')
+        class RockNRollConfig(AppConfig):
+            # ...
+
+            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::