March 2020
Intermediate to advanced
608 pages
17h 17m
English
After calling django.setup(), you can load the app configurations and models from the registry as follows:
>>> from django.apps import apps as django_apps>>> magazine_app_config = django_apps.get_app_config("magazine")>>> magazine_app_config<MagazineAppConfig: magazine>>>> magazine_app_config.models_module<module 'magazine.models' from '/path/to/myproject/apps/magazine/models.py'>>>> NewsArticle = django_apps.get_model("magazine", "NewsArticle")>>> NewsArticle<class 'magazine.models.NewsArticle'>
You can read more about app configuration in the official Django documentation at https://docs.djangoproject.com/en/2.2/ref/applications/.