#8458 closed (worksforme)
adding own commands to manage.py not working correctly
Reported by: | dafire | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I tried to add my own commands as described in http://www.djangoproject.com/documentation/django-admin/ but it did not find my commands.
I did some research and found a problem.
lets assume I have
INSTALLED_APPS = ( 'proj.app' )
and call manage.py from the /var/www/proj folder it looks for the "management" class in /var/www/proj/proj/app/management
I added sys.path = ['..']+sys.path
to "django\core\management\__init__.py"
as a local fix and it worked after that.
Change History (6)
comment:1 by , 16 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | duplicate |
---|---|
Status: | closed → reopened |
How on earth can a bug be fixed if the fix hasn't been checked in? This is a new bug (or at least a new manifestation of an old one).
comment:3 by , 16 years ago
milestone: | → 1.0 |
---|---|
Triage Stage: | Unreviewed → Accepted |
follow-up: 5 comment:4 by , 16 years ago
Component: | Uncategorized → django-admin.py |
---|---|
Resolution: | → worksforme |
Status: | reopened → closed |
Replying to dafire:
I tried to add my own commands as described in http://www.djangoproject.com/documentation/django-admin/ but it did not find my commands.
I did some research and found a problem.
[snipped]
and call manage.py from the /var/www/proj folder it looks for the "management" class in /var/www/proj/proj/app/management
Looks like you are misinterpreting the docs. You need to create a folder called "management" in your app and in it create an empty __init__.py
alongwith a sub-folder called "commands". Each command will have a separate file and will be under the "commands" folder. Also remember to create another empty __init__.py
file in the commands folder. Each command file should contain a class "Command" that should override a method "handle" that does whatever you want when the command is invoked.
The command tree should look something like this:
proj/ settings.py app/ models.py management/ __init__.py commands/ __init__.py mycommand.py
Please reopen the ticket if I've got something wrong with what you meant to convey.
This is almost certainly a duplicate of #5825 which is fixed but apparently not checked in yet.