From 94b5bc361aef2ae2d46a49dbfe32d9271c185800 Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Sat, 15 Feb 2014 17:27:12 +0100 Subject: Fixed #22002 -- Documented avoiding database interaction in AppConfig.ready(). Thanks Marc Tamlyn for the suggestion. --- docs/ref/applications.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/applications.txt b/docs/ref/applications.txt index be86f42305..2a5128ebb8 100644 --- a/docs/ref/applications.txt +++ b/docs/ref/applications.txt @@ -221,6 +221,19 @@ Methods def ready(self): MyModel = self.get_model('MyModel') + .. warning:: + + Although you can access model classes as described above, avoid + interacting with the database in your :meth:`ready()` implementation. + This includes model methods that execute queries + (:meth:`~django.db.models.Model.save()`, + :meth:`~django.db.models.Model.delete()`, manager methods etc.), and + also raw SQL queries via ``django.db.connection``. Your + :meth:`ready()` method will run during startup of every management + command. For example, even though the test database configuration is + separate from the production settings, ``manage.py test`` would still + execute some queries against your **production** database! + .. _namespace package: Namespace packages as apps (Python 3.3+) -- cgit v1.3