0

EDIT: management commands. Not comments. Auto correct..

I was using django 1.7.final.0 for a while, but am now trying to upgrade to 1.8 (..and eventually to the newest version).

When running manage.py help, the commands I see are only the base commands.

I've added a print statement, to see if INSTALLED_APPS works and it does.

import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
    from config import settings
    print(settings.INSTALLED_APPS) # prints apps like django-extensions that have commands.
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

There are no errors, but it simply doesn't list the other commands. If I try to run a command, like ./manage.py shell_plus it returns Unknown Command as can be seen below. Note the print statement, indicating that INSTALLED_APPS can be read.

(venv) rootadmin@annotatie01:/data_nfs/opensurfaces2/server$ python manage.py shell_plus
('admin_tools', 'admin_tools.theming', 'admin_tools.menu', 'admin_tools.dashboard', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.humanize', 'gunicorn', 'storages', 'queued_storage', 'django_extensions', 'account', 'django_forms_bootstrap', 'imagekit', 'compressor', 'endless_pagination', 'cacheback', 'captcha', 'mptt', 'debug_toolbar', 'cache_panel', 'memcache_status', 'common', 'home', 'accounts', 'analytics', 'licenses', 'poly', 'mturk', 'categories', 'photos', 'shapes', 'bsdfs', 'normals', 'intrinsic', 'points', 'boxes', 'matclass', 'paintings', 'binaryQuestion')
Unknown command: 'shell_plus'
Type 'manage.py help' for usage.
(venv) rootadmin@annotatie01:/data
Mitchell van Zuylen
  • 3,905
  • 4
  • 27
  • 64

2 Answers2

1

Make sure you have upgraded django-extensions (which contains shell_plus) at the same time as Django, so that you have a compatible version installed.

At the time of writing, the latest release django-extensions 1.9.9 appears to support Django 1.8. However in future you may find that the latest version does not support Django 1.8 after it goes end of life in April 2018.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Tried that. Next to `django-extensions` there are 10 more apps that have custom commands that are not being loaded. – Mitchell van Zuylen Feb 21 '18 at 11:56
  • I don't have any other suggestions, you might have to step through the code with a debugger to try to figure out why the custom commands are not being loaded. I would remove the `import` and `print` statement from `manage` now that you have verified `INSTALLED_APPS` - importing the settings directly is not recommended. – Alasdair Feb 21 '18 at 12:00
  • To test, I made some changes to a model and found that running `makemigrations` detects no changes. If I force `makemigrations app_name` it returns `App 'app_name' could not be found. Is it in INSTALLED_APPS?` (it is). This appears to have the same underlying problem. Could it be that installed_apps can be loaded by that import, but is still not being used? – Mitchell van Zuylen Feb 21 '18 at 12:04
  • I'm afraid I don't understand your comment. If you expand your question and give more info it might be clearer what the problem is. – Alasdair Feb 21 '18 at 12:23
0

The problem was in a dependencies. As this answer says MPTT was in need of an update.

I upgraded using the below, and now it works.

python -m pip install 'django-mptt==0.7'
Mitchell van Zuylen
  • 3,905
  • 4
  • 27
  • 64