Django: Dynamically add apps as plugin, building urls and other settings automatically

后端 未结 5 1352
慢半拍i
慢半拍i 2021-01-03 01:29

I have following structure of my folders in Django:

./project_root
    ./app
       ./fixtures/
       ./static/
       ./templates/
       ./blog/
       ./         


        
5条回答
  •  無奈伤痛
    2021-01-03 02:14

    It is best practice not to access INSTALLED_APPS directly as stated in django docs but to use the registry instead:

    from django.apps import apps
    
    for app in apps.get_app_configs():
        app_name = app.name
        try:
            ...
    

提交回复
热议问题