7

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?

1
  • 1
    --help does not work?
    – NullSpace
    Feb 5, 2014 at 1:30

1 Answer 1

9

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 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.