Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#22942 closed Cleanup/optimization (fixed)

Custom django-admin commands - __init__.py in directories

Reported by: Diego Cerdán <diegocerdan@…> Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Documentation should state that the file init.py is required in the management and commands directories.

https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

Some people (included me) got confused but luckly is solved in this Stackoverflow question:
http://stackoverflow.com/questions/17962454/how-to-write-custom-django-manage-py-commands-in-multiple-apps

Change History (7)

comment:1 Changed 9 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

The first example includes both __init__.py files. Does it really need special emphasis?

comment:2 Changed 9 months ago by aaugustin

I don't believe these files are required on Python 3. (It may remain a good idea to include them.)

comment:3 Changed 9 months ago by timo

  • Resolution set to worksforme
  • Status changed from new to closed

Confirmed they are not required on Python 3.

On Python 2, the error is ImportError: No module named management.commands.mycommand. I think that's a fairly intuitive message to indicate that the modules aren't properly configured.

comment:4 Changed 9 months ago by timo

  • Resolution worksforme deleted
  • Status changed from closed to new

Reported again in #22974 so I'm going to add some emphasis about this.

comment:5 Changed 9 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 54546cee88f1db4e7e0ad75ebb9672c118b2236c:

Fixed #22942 -- Noted that init.py files are required for management command detection.

Thanks Diego Cerdán for the suggestion.

comment:6 Changed 9 months ago by Tim Graham <timograham@…>

In 837cad0f6242f5292b8a4811fc48fbfbefe92a47:

[1.6.x] Fixed #22942 -- Noted that init.py files are required for management command detection.

Thanks Diego Cerdán for the suggestion.

Backport of 54546cee88 from master

comment:7 Changed 9 months ago by Tim Graham <timograham@…>

In c379fc4eec885101ac30e0505f967048c869e630:

[1.7.x] Fixed #22942 -- Noted that init.py files are required for management command detection.

Thanks Diego Cerdán for the suggestion.

Backport of 54546cee88 from master

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