django / django/new-features

Getting the `app_label` information on `post_migrate` signal

Open
#52 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

`post_migrate` send the callback function an additional argument `app_label` that was passed to `manage.py` command line argument.

### Problem

I would like to get the `app_label` via the arguments come through the callback for `post_migrate`. I'm aware that `apps` argument has the whole list of installed apps. What I would like to get is the specific app on which the `migrate` command was executed.

Let's say I have multiple apps with models in my project. I would like to execute some callback functions on `post_migrate` signal, but only when the specific app was run, for example, if I run `python manage.py migrate` or `python manage.py migrate user`, then the callback function in my `user` app would run. In this case, it doesn't matter if `plan` argument is empty or not. When I run `python manage.py migrate blog` which does not depend on `user` app, then the callback function does not run.

I can check when the specific app is in the `plan` argument. For example, some migration depends on the app's model. However, when the plan is empty, I don't have any manner to check if the command was executed on a specific app.

### Request or proposal

request

### Additional Details

_No response_

### Implementation Suggestions

Adding an argument for `emit_post_migrate_signal` function, perhaps?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the post_migrate signal dispatch and the emit_post_migrate_signal function, then follow how the migrate command receives an app label from manage.py. Define how the callback should identify an explicitly selected app versus a full migration, and add coverage for empty plans and unrelated apps.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.