Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8660579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:17:14+00:00 2026-06-12T16:17:14+00:00

The Django management commands documentation shows all commands being created in an app/management/commands folder.

  • 0

The Django management commands documentation shows all commands being created in an app/management/commands folder. Is it possible to put commands into subfolders, like app/management/commands/install and app/management/commands/maintenance? How would this be done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:17:16+00:00Added an answer on June 12, 2026 at 4:17 pm

    Unfortunatly, as of Django 1.4 there seems to be no way of doing that. The sources for django.core.management.__init__.py have this method:

    def find_commands(management_dir):
        """
        Given a path to a management directory, returns a list of all the command
        names that are available.
    
        Returns an empty list if no commands are defined.
        """
        command_dir = os.path.join(management_dir, 'commands')
        try:
            return [f[:-3] for f in os.listdir(command_dir)
                    if not f.startswith('_') and f.endswith('.py')]
        except OSError:
           return []
    

    As you can see, it only considers files directly inside the commands folder, ignoring any subfolders. However, if you "monkey patch" this function somehow, the rest of the code should work fine, since the code that actually creates the Command instance is this:

    def load_command_class(app_name, name):
        """
        Given a command name and an application name, returns the Command
        class instance. All errors raised by the import process
        (ImportError, AttributeError) are allowed to propagate.
        """
        module = import_module('%s.management.commands.%s' % (app_name, name))
        return module.Command()
    

    So, if you had a command named subfolder.command it would load the right script and instantiate the right class.

    From a practical standpoint, however, I see no use of doing that. Sure, having "namespace’d" commands would be nice, but you can always prefix all your commands with some name if you want, using something else as a separator (such as _). The command name length – and the number of keystrokes needed to type them in the terminal – will be the same…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a fixtures folder in the app directory and put data1.json in there.
I have a a number of management commands in my Django application. I'd like
I need to run a lot of Django management commands in the crontab and
I have a Django 1.3 application. I have several management commands. I want each
I am writing a management command for Django and I created template files that
I have a new Django 1.3 project and app that I've created. I added
Is it possible to selectively filter which records Django's dumpdata management command outputs? I
I'm new to Django. I have created a new App called Directorio and now
I followed the heroku documentation to install a django app and at first it
>>> from django.core.management import call_command >>> call_command('syncdb') executes the syncdb management command from within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.