Dimitris Kougioumtzis Blog About technology

Itterate apps

Category Django

Posted on Dec. 29, 2017



Itterate apps


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from django.apps import apps
from django.conf import settings

def get_apps(request):
    apps_list = {}
    for app in settings.INSTALLED_APPS:
        if 'django' in app:
            pass
        else:
            app_models = apps.get_app_config(app).get_models()
            apps_list[app] = [model for model in app_models]
            if len(apps_list[app]) == 0:
                del apps_list[app]

    return {
        'apps': apps_list
    }

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere