Reputation: 5242
I've create a command in app/management/commands and this command was working fine. I'm unable to run this command now. I'm getting the following error:
Unknown command: 'my_custom_command_name'
I'm using a virtual env. I don't see this in list of commands when I type pythong manage.py
. I've this app installed in my settings and It was working previously
Upvotes: 2
Views: 3861
Reputation: 216
Sometimes this can happen if you haven't added your app to
INSTALLED_APPS = [ 'app', ]
in settings.py
Upvotes: 0
Reputation: 15548
Sufficient conditions:
1) The management command can be imported by:
$ python manage.py shell
>>> from yourapp.management.commands import yourcommand
(If it can't be imported then you probably easily get more details about the specific import problem. An answer can be eventually much easier searched or it is usually very trivial.)
2) The app implementing a management command for Django should be installed as a directory with individual files, not compressed into egg file. You can use the keyword parameter zip_safe=False
in setup.py
for preventing zipped installation. (This parameter is frequently not necessary if the False
value is recognized correctly by autodetection. So it is even more surprising in other cases.)
Upvotes: 8
Reputation: 5242
That's really weird. When I tried to run:
$ python manage.py shell
I got the following error:
Error: cannot import name urandom
I searched for the error and found that I need to recreate my virtual env so I used the following command:
virtualenv /path/to/my/virtualenv
and then I was able to use django commands or my custom command the usual way :s
Upvotes: 1