瀏覽代碼

Fixed #22748 -- Corrected post_migrate usage example.

Thanks Rudolph for the report.
Tim Graham 10 年之前
父節點
當前提交
a00efa30d6
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      docs/ref/signals.txt

+ 8 - 3
docs/ref/signals.txt

@@ -491,16 +491,21 @@ Arguments sent with this signal:
     The database alias used for synchronization. Defaults to the ``default``
     database.
 
-For example, ``yourapp/management/__init__.py`` could be written like::
+For example, you could register a callback in an
+:class:`~django.apps.AppConfig` like this::
 
+    from django.apps import AppConfig
     from django.db.models.signals import post_migrate
-    import yourapp.models
 
     def my_callback(sender, **kwargs):
         # Your specific logic here
         pass
 
-    post_migrate.connect(my_callback, sender=yourapp.models)
+    class MyAppConfig(AppConfig):
+        ...
+
+        def ready(self):
+            post_migrate.connect(my_callback, sender=self)
 
 post_syncdb
 -----------