Search code examples
pythondjangodjango-manage.pymanage.py

django-admin.py doesn't find management commands but manage.py does


I have a Django project with management commands in called "listen_rfid" and "listen_qr". They both show up in

./manage.py help --settings=imagination.idmapper.config.settings_dev

but neither show up in

django-admin.py help --settings=imagination.idmapper.config.settings_dev
  • I have diffed the output of diffsettings from django-admin.py and manage.py and there are no differences.
  • My apps are correctly listed in INSTALLED_APPS.
  • DJANGO_SETTINGS_MODULE is set the same in my environment and in manage.py.
  • I am able to import my management commands as a python module and run them from the django-admin.py shell.
  • I'm working in a virtualenv, but the django-admin.py command is the one installed within it, as evidenced by 'which django-admin.py'.

What could be any possible reasons for django-admin.py acting differently to manage.py?

I'm using Django 1.5.5 on Ubuntu 12.04


Solution

  • Finally found the answer to this question! Here's a quote from the django bug report:

    django.core.management.find_management_module() loads custom commands for manage.py by finding the path of the module and examining file directly. This fails when apps are within packages that share a common base name, but where the files are NOT in the same directories, example:

    • app 1: company.division.project_a.app1 stored in path packages/company.subdivision.project_a.app1
    • app 2: company.division.project_b.app2 stored in path packages/company.subdivision.project_b.app2

    Custom commands in app 2 will not be found.