How it works...

When you run an HTTP server or invoke a management command, django.setup() is called. It loads the settings, sets up logging, and prepares the app registry. This registry is initialized in three steps. Django first imports the configurations for each item from INSTALLED_APPS in the settings. These items can point to app names or configurations directly—for example, "myproject.apps.magazine" or "myproject.apps.magazine.apps.MagazineAppConfig".

Django then tries to import models.py from each app in INSTALLED_APPS and collect all of the models.

Finally, Django runs the ready() method for each app configuration. This method presents a good point in the development process to register signal handlers, if you have any. The ready() method is optional.

In our example, the MagazineAppConfig class sets the configuration for the magazine app. The name parameter defines the module of the current app. The verbose_name parameter defines a human name that is used in the Django model administration, where models are presented and grouped by apps. The ready() method imports and activates the signal handlers that, when in DEBUG mode, print in the terminal that a NewsArticle object was saved or deleted.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.233.41