#30098: Permit using packages (directories) in custom django-admin commands.
-------------------------------------+-------------------------------------
Reporter: Andrey Volkov | Owner: Andrey
| Volkov
Type: New feature | Status: assigned
Component: Core (Management | Version: 2.1
commands) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Andrey Volkov):
Replying to [comment:2 Tim Graham]:
> At first glance, I'm not in favor of the extra complexity this would
introduce. Django stores helper files for its own commands in the
`management` directory (`django/core/managment`) which seems fine.
Yeah, this can increase complexity, but this feature is not obligatory.
Developers can write management commands the same way as before.
Why I want this change, is because it solves and/or simplifies some
problems (mine too). For example, we could have a library that assumes
some filenames to be `data.json` and we want to use this library in the
number of commands. With directories style it can be solved like this:
{{{
app_example/management/commands
├── first_command
│ ├── data.json
│ └── __init__.py
└── second_command
├── data.json
└── __init__.py
}}}
With files-only style it (with some changes to library behavior) should
be:
{{{
app_example/management
├── commands
│ ├── first_command.py
│ └── second_command.py
├── first_command_data.json
└── second_command_data.json
}}}
Last solution gives duplicated command names. That means if developer
changes a command name, it should be changed at least twice (against one
change in directory approach).
Also, this style gives possibility for encapsulation. Django wouldn't know
how the command is structured (is it file or directory) it will just use
it as a regular module, that contains a `Command` class.
Last point I want to mention here, is that it can help Django in the
future. If additional functionality will be given to the management module
(some features except commands), encapsulation will prevent storing random
files (that refer only to commands) in management directory. And change,
that enables directory-based commands, is extremely small, so that it
affects only parsing the `app/management/commands` directory (it is
literally removes only one condition).
Sorry for such a long comment, but I really think that this feature will
help developers both now and in the future.
--
Ticket URL: <https://code.djangoproject.com/ticket/30098#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.ce294e14e50458cf4843f9e558d3d96f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.