o 3a3@srddlZddlZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z dZdZGd d d ZdS) N) import_module)ImproperlyConfigured)RemovedInDjango41Warning)cached_property) import_stringmodule_has_submoduleappsmodelsc@speZdZdZddZddZeddZedd Z d d Z e d d Z dddZ dddZddZddZdS) AppConfigz>Class representing a Django application and its configuration.cCs||_||_d|_t|ds|dd|_|js"td|jt|ds-|j|_ t|ds8| ||_ d|_ d|_ dS)Nlabel.z4The app label '%s' is not a valid Python identifier. verbose_namepath)namemodulerhasattr rpartitionr isidentifierrtitler_path_from_moduler models_moduler )selfapp_name app_moduler4/usr/lib/python3/dist-packages/django/apps/config.py__init__s       zAppConfig.__init__cCsd|jj|jfS)Nz<%s: %s>) __class____name__r rrrr__repr__<szAppConfig.__repr__cCsddlm}|jS)Nr)settings) django.confr"DEFAULT_AUTO_FIELD)rr"rrrdefault_auto_field?s zAppConfig.default_auto_fieldcCs|jjtjuS)N)rr%r r rrr!_is_default_auto_field_overriddenDsz+AppConfig._is_default_auto_field_overriddencCstt|dg}t|dkr&t|dd}|dur tj|g}ntt|}t|dkr4td||f|ss z$AppConfig.create..r(rcSs$g|]\}}t|ddr||fqS)r3F)r+r5rrrr:s  cSsg|]\}}t|qSr)repr)r6r_rrrr:sz0%r declares more than one default AppConfig: %s.z, z$%r defines default_app_config = %r. zWDjango now detects this configuration automatically. You can remove default_app_config.zHowever, Django's automatic detection %s. You should move the default config class to the apps submodule of your application and, if this module defines several config classes, mark the default one with default = True.z picked another configuration, %rzdid not find this configurationr ) stacklevelr cs*g|]\}}t|r|urt|qSr)r4r;r5r8rrr:sz*Module '%s' does not contain a '%s' class.z Choices are: %s.z#'%s' isn't a subclass of AppConfig.z"'%s' must supply a name attribute.z7Cannot import '%s'. Check that '%s.%s.name' is correct.)r ExceptionrAPPS_MODULE_NAMEinspect getmembersisclassr, RuntimeErrorjoindefault_app_configAttributeErrorwarningswarnrrrisupper ImportErrorr4r rr __module__ __qualname__)r9entryapp_config_classapp_config_namerrmod_pathmod app_configs candidates new_entrymessager<cls_namemsgrr8rcreatecs                         zAppConfig.createTcCsL|r|jn|jz|j|WSty%td|j|fw)z Return the model with the given case-insensitive model_name. Raise LookupError if no model exists with this name. z#App '%s' doesn't have a '%s' model.)rcheck_models_readycheck_apps_readyr lowerKeyError LookupErrorr )r model_name require_readyrrr get_models    zAppConfig.get_modelFccsB|j|jD]}|jjr|sq |jjr|sq |Vq dS)a Return an iterable of models. By default, the following models aren't included: - auto-created models for many-to-many relations without an explicit intermediate table, - models that have been swapped out. Set the corresponding keyword argument to True to include such models. Keyword arguments aren't documented; they're a private API. N)rrYr values_meta auto_createdswapped)rinclude_auto_createdinclude_swappedmodelrrr get_modelss   zAppConfig.get_modelscCs<|jj|j|_t|jtrd|jtf}t||_ dSdS)Nr2) r all_modelsr r rrMODELS_MODULE_NAMErrr)rmodels_module_namerrr import_models&s  zAppConfig.import_modelscCsdS)zT Override this method in subclasses to run code when Django starts. Nrr rrrready/szAppConfig.readyN)T)FF)rrKrL__doc__rr!rr%propertyr&r classmethodrXr`rhrlrmrrrrr s *      r )r@r-rG importlibrdjango.core.exceptionsrdjango.utils.deprecationrdjango.utils.functionalrdjango.utils.module_loadingrrr?rjr rrrrs