1

Is there a way to get a list of all the project-specific apps in a Django project? settings.INSTALLED_APPS will give me a list of all apps I have installed, but that includes things like django.contrib.auth. I just want the apps I have generated using the createapp command.

As a follow up question, is there a way to dynamically get a list of every module in a given app?

user1427661
  • 11,158
  • 28
  • 90
  • 132

1 Answers1

5

There's no flag that keeps track of which apps are generated by startapp. However you can separate INSTALLED_APPS into two lists:

APPS = [
    'django.contrib.auth',
    # ...
]

MY_APPS = [
    'myapp1',
    # ...
]

INSTALLED_APPS = APPS + MY_APPS

You can then use settings.MY_APPS as a list of your apps.

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
  • Yeah. This is a smart way to do it. – karthikr Nov 21 '13 at 17:25
  • As of end 2022, [this](https://stackoverflow.com/questions/4111244/get-a-list-of-all-installed-applications-in-django-and-their-attributes) gets us the list of apps (`INSTALLED_APPS`) with elan as put forward by @nttaylor. To repeat his solution, it is `apps.app_configs.keys()`. – carla Dec 07 '22 at 04:26