Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all installed apps with manage.py in Django?

Tags:

django

Some manage.py commands take Django applications as arguments. Sometimes I want to use these commands, but can't remember the name of the application. Is there a way to get manage.py to provide a such a list?

like image 925
Casebash Avatar asked Feb 05 '14 01:02

Casebash


People also ask

How do I see installed apps in Django?

The list of installed applications is defined in settings. INSTALLED_APPS . It contains a tuple of strings, so you can iterate on it to access each application's name.

What file contains the list of installed apps in a Django project?

The project's root directory or the one that has manage.py usually contains all project's applications which are not separately installed.


1 Answers

not ready made, but you can pipe:

$ echo 'import settings; settings.INSTALLED_APPS' | ./manage.py shell
...
>>> ('django.contrib.auth', 'django.contrib.contenttypes', 
     'django.contrib.sessions', 'django.contrib.sites'...]

or write a small custom command:

import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
    def handle(self, *args, **options):
        print settings.INSTALLED_APPS

or in a more generic way:

import settings
from django.core.management.base import BaseCommand
class Command(BaseCommand):
    def handle(self, *args, **options):
        print vars(settings)[args[0]]

$ ./manage.py get_settings INSTALLED_APPS
('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 
 'django.contrib.sites', ...]
$ ./manage.py get_settings TIME_ZONE
America/Chicago 
like image 179
Guy Gavriely Avatar answered Sep 28 '22 16:09

Guy Gavriely