#27747: Add signals for Django management commands -------------------------------------+------------------------------------- Reporter: Dmitry | Owner: nobody Gladkov | Type: New | Status: new feature | Component: Core | Version: master (Management commands) | Severity: Normal | Keywords: Triage Stage: | Has patch: 0 Unreviewed | Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | Easy pickings: 0 UI/UX: 0 | -------------------------------------+------------------------------------- Related PR: https://github.com/django/django/pull/7857
Suggested example usage (I know that a string can't be a signal sender, this is just for illustrating the point): {{{#!python from django.core.management import signals def handle_pre(sender, instance): instance.stdout.write('Hello World') def handle_post(sender, instance): instance.stdout.write('Bye World') signals.pre_command.connect(handle_pre, sender='runserver') signals.post_command.connect(handle_post, sender='runsever') }}} Reasoning: Currently overriding of commands in Django can only be achieved by shadowing existing commands using `INSTALLED_APPS` initialization order. This is a perfectly good solution if a user needs to completely override a command, but it's not ideal for extending/adding functionality to existing commands. Extending the same command from different apps will not work as only the extended command from the latest `INSTALLED_APPS` entry will run (see Example 2). Some examples of actions that can be achieved using singals: 1. Pulling remote translations before `compilemessages`. 2. Showing coverage or/and generating xml report after `test`. 3. Running optipng on collected static images after `collectstatic` 4. Displaying useful information like outdated package versions before `runserver`. -- Ticket URL: <https://code.djangoproject.com/ticket/27747> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/046.36b28dd3aed61c03394956a205d61cd5%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.