You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, models present in packages or modules are not initialized in app_configs of apps within the django.apps module.
This leads to issue where the models are not returned with apps.get_models(). This have implications on some default functions given by ContentType model like model_class()
Proposed Solution:
To address this, I propose an enhancement to dynamically update app_configs with models discovered at runtime. Specifically, we can introduce a mechanism to update app_configs with dynamic models when running the server or executing commands.
Implementation Details:
Retrieve Dynamic Models: Obtain a list of all dynamic models that need to be registered.
Update app_configs: Modify the app_configs dictionary to include these dynamic models. This can be achieved by updating the models attribute of the relevant AppConfig instances.
Example Code Snippet:
from django.apps import apps app_config = apps.app_configs.get('dynamic_models') if app_config: app_config.models.update({ '<model_name>': <model_class> })
The text was updated successfully, but these errors were encountered:
Currently, models present in packages or modules are not initialized in app_configs of apps within the django.apps module.
This leads to issue where the models are not returned with apps.get_models(). This have implications on some default functions given by ContentType model like model_class()
Proposed Solution:
To address this, I propose an enhancement to dynamically update app_configs with models discovered at runtime. Specifically, we can introduce a mechanism to update app_configs with dynamic models when running the server or executing commands.
Implementation Details:
Retrieve Dynamic Models: Obtain a list of all dynamic models that need to be registered.
Update app_configs: Modify the app_configs dictionary to include these dynamic models. This can be achieved by updating the models attribute of the relevant AppConfig instances.
Example Code Snippet:
from django.apps import apps
app_config = apps.app_configs.get('dynamic_models')
if app_config:
app_config.models.update({
'<model_name>': <model_class>
})
The text was updated successfully, but these errors were encountered: