django/django · error · CommandError
You must supply at least one app label when using --empty.
Error message
You must supply at least one app label when using --empty.
What it means
The --empty flag tells makemigrations to create a blank migration skeleton (no auto-detected operations), but the command needs to know which app to create it for. Without at least one positional app_label argument, there is no target directory (app/migrations/) to write the file into. The check at line 223 fires when `self.empty` is True and `app_labels` is empty.
Source
Thrown at django/core/management/commands/makemigrations.py:224
)
else:
questioner = NonInteractiveMigrationQuestioner(
specified_apps=app_labels,
dry_run=self.dry_run,
verbosity=self.verbosity,
log=self.log,
)
# Set up autodetector
autodetector = self.autodetector(
loader.project_state(),
ProjectState.from_apps(apps),
questioner,
)
# If they want to make an empty migration, make one for each app
if self.empty:
if not app_labels:
raise CommandError(
"You must supply at least one app label when using --empty."
)
# Make a fake changes() result we can pass to arrange_for_graph
changes = {app: [Migration("custom", app)] for app in app_labels}
changes = autodetector.arrange_for_graph(
changes=changes,
graph=loader.graph,
migration_name=self.migration_name,
)
self.write_migration_files(changes)
return
# Detect changes
changes = autodetector.changes(
graph=loader.graph,
trim_to_apps=app_labels or None,
convert_apps=app_labels or None,
migration_name=self.migration_name,View on GitHub (pinned to ae25a40be0)
Solutions
- Add the app label: `python manage.py makemigrations --empty myapp`
- Optionally combine with -n to name it: `python manage.py makemigrations --empty myapp -n custom_data`
Example fix
// before python manage.py makemigrations --empty // after python manage.py makemigrations --empty myapp -n custom_data
Defensive patterns
Strategy: validation
Validate before calling
from django.core.management import call_command
app_labels = ["myapp"] # must be non-empty when empty=True
if not app_labels:
raise ValueError("At least one app label is required with --empty")
call_command("makemigrations", *app_labels, empty=True) Type guard
def has_app_labels(app_labels) -> bool:
"""True if at least one app label is provided for --empty mode."""
return bool(app_labels) and all(isinstance(a, str) and a for a in app_labels) Try / catch
from django.core.management import call_command
from django.core.management.base import CommandError
try:
call_command("makemigrations", empty=True)
except CommandError as e:
if "supply at least one app label" in str(e):
call_command("makemigrations", "myapp", empty=True)
else:
raise Prevention
- Always pair --empty with an explicit app label argument
- Use shell completion or aliases that include the app label by default
When it happens
Trigger: Running `python manage.py makemigrations --empty` with no app label arguments. Also via `call_command('makemigrations', empty=True)` with no positional args.
Common situations: Developer wants a hand-written data migration but forgets to specify the app, or assumes --empty applies to all apps.
Related errors
- The migration name must be a valid Python identifier.
- "%s" is not a valid port number or address:port pair.
- %r is not a valid port number.
- "%s" is not a valid IPv6 address.
- App '%s' doesn't have a '%s' model.
AI-assisted analysis of django/django@ae25a40be0 (2026-08-06).
Data as JSON: /api/errors/3dc4f2d33d856291.
Report an issue: GitHub.