Opened 5 months ago
Closed 5 months ago
#36322 closed New feature (duplicate)
"Enhance manage.py CLI: Suggest alternatives for unknown commands (typo correction)"
Reported by: | Rishav | Owned by: | |
---|---|---|---|
Component: | Core (Management commands) | Version: | 5.2 |
Severity: | Normal | Keywords: | CLI management commands typo correction command suggestions difflib Dev UX Django improvement error handling command-line interface helpful error messages Django core |
Cc: | Rishav | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description
When using manage.py, if a user enters an incorrect or misspelled command, Django currently does not provide suggestions for the correct command. This can lead to frustration, especially for developers who may make typographical errors or are unsure of the exact command name.
Proposed Solution: Enhance the manage.py command-line interface to automatically suggest possible alternatives for unknown commands. The suggestion should be based on a comparison between the user’s input and the available commands using Python’s built-in difflib.get_close_matches() function. This will help users by displaying a helpful message indicating potential command suggestions.
Change History (6)
follow-up: 4 comment:2 by , 5 months ago
UI/UX: | unset |
---|
comment:3 by , 5 months ago
UI/UX: | set |
---|
comment:4 by , 5 months ago
Re-enabling the UI/UX flag since this feature directly impacts the developer experience when interacting with the CLI. While it's not a graphical interface, improving how Django handles mistyped commands (by suggesting close matches) significantly enhances usability and reduces friction for users, especially beginners. Happy to clarify further if needed!Replying to Clifford Gama:
comment:6 by , 5 months ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
### Examples:
python manage.py runsever
Expected Output:` Unknown command: 'runsever'. Did you mean 'runserver'?
`
python manage.py makemgrations
Expected Output:` Unknown command: 'makemgrations'. Did you mean 'makemigrations' or 'migrate'?
`
python manage.py foo
Expected Output:` Unknown command: 'foo'. No similar commands found.
`
python manage.py runserver
Expected Output:` Running server as expected (no suggestion needed).
`