0

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

Ellis Percival
  • 4,632
  • 2
  • 24
  • 34
  • Just to be sure, if you do `$ which django-admin.py` you get the one from your virtualenv right? – ptr Jan 09 '14 at 17:04
  • is your PYTHONPATH set correctly? try `export PYTHONPATH=/path/to/project` – ptr Jan 09 '14 at 17:07
  • My above comment was assuming you were on linux btw, apologies for that. Either way you need to make sure your project directory is on the PYTHONPATH, something that manage.py does automatically but django-admin.py does not. – ptr Jan 09 '14 at 17:15
  • Yeah, my project directory is on PYTHONPATH. manage.py doesn't appear to set that though, only the DJANGO_SETTINGS_MODULE: http://pastebin.com/wXmNwamb – Ellis Percival Jan 09 '14 at 17:17

2 Answers2

2

According to documentation

django-admin.py is Django’s command-line utility for administrative tasks. This document outlines all it can do.

In addition, manage.py is automatically created in each Django project. manage.py is a thin wrapper around django-admin.py that takes care of two things for you before delegating to django-admin.py:

1) It puts your project’s package on sys.path. 2) It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file. 3) It calls django.setup() to initialize various internals of Django.

There could be possibly a problem with point 1 or 3. By the ways, I've always used ./manage.py with no problem at all in django 1.5

https://docs.djangoproject.com/en/dev/ref/django-admin/

finiteautomata
  • 3,753
  • 4
  • 31
  • 41
0

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.

Community
  • 1
  • 1
Ellis Percival
  • 4,632
  • 2
  • 24
  • 34