Code

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#3528 closed (wontfix)

simple cli extensions for django-admin.py and manage.py

Reported by: Ronny Pfannschmidt Owned by: adrian
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

just ran across the point where its nice to have custom commands for the cli

it would simplify setting up daily actions and other tasks wich arent well-suited for the web interface

it would be nice to have something like

./manage.py run $myapp $mycommand $myargs

## examples
./manage.py run sessions clean
./manage.py run notifications daily
./manage.py run forum update post_cache

Attachments (1)

manage.py (1.6 KB) - added by phil.h.smith@… 7 years ago.
pseudo code for overriding execute_manager to add custom ./manage.py actions

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by phil.h.smith@…

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

We worked out a sketch of how to try this in the irc (see attachment.) We found we had to duplicate django.core.management.execute_manager so we could customize action_mapping before passing to execute_from_command_line.

There seem to be some ways to make this happier and drier. The one that seems cleanest to me is to give execute_manager a default-able action_mapping parameter that would augment and/or replace the default one. Another is to remove the startapp/startproject magic from it (leaving it basically empty) so we don't feel bad duplicating 'n overriding.

Changed 7 years ago by phil.h.smith@…

pseudo code for overriding execute_manager to add custom ./manage.py actions

comment:2 Changed 7 years ago by Ronny Pfannschmidt <ronny.pfannschmidt@…>

nice method, but it's on project basis

usually applications need the custom commands, not projects (wich are just combinations of applications)

comment:3 follow-up: Changed 7 years ago by ramiro <rm0 _at_ gmx.net>

See #2868

comment:4 in reply to: ↑ 3 Changed 7 years ago by anonymous

  • Triage Stage changed from Unreviewed to Design decision needed

#2868 is about project level scripts, this ticket about application level scripts, so it's not a duplicate.

comment:5 Changed 7 years ago by mir@…

Last comment was from me, sorry.

comment:6 Changed 7 years ago by mtredinnick

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

All manage.py does is set DJANGO_SETTINGS_MODULE in the environment and puts the current project is on the path. So it's trivial to replicate that for scripts you want to run -- like literally one line.

It doesn't make sense to think of manage.py on a per-app level, outside of projects, because settings files are on a project level. If your apps aren't all under one project, you need to set the Python paths manually yourself anyway so that they are accessible (if not on default paths), so manage.py doesn't help you there.

This isn't worth implementing because it doesn't really make anything easier than it already is.

comment:7 Changed 6 years ago by jacob

  • Reporter changed from Ronny Pfannschmidt <ronny.pfannschmidt@…> to Ronny Pfannschmidt

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.