Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8458 closed (worksforme)

adding own commands to manage.py not working correctly

Reported by: dafire Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 Changed 7 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

This is almost certainly a duplicate of #5825 which is fixed but apparently not checked in yet.

comment:2 Changed 7 years ago by russellm

  • Resolution duplicate deleted
  • Status changed from closed to 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 Changed 7 years ago by mtredinnick

  • milestone set to 1.0
  • Triage Stage changed from Unreviewed to Accepted

comment:4 in reply to: ↑ description ; follow-up: Changed 7 years ago by anonymous

  • Component changed from Uncategorized to django-admin.py
  • Resolution set to worksforme
  • Status changed from reopened to 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.

comment:5 in reply to: ↑ 4 Changed 7 years ago by thejaswi_puthraya

Replying to anonymous:
[snipped]
Oops...the previous replier was me :)

comment:6 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Note: See TracTickets for help on using tickets.
Back to Top