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)

comment:1 by Rishav, 5 months ago

### Examples:

  1. Input: python manage.py runsever Expected Output: ` Unknown command: 'runsever'. Did you mean 'runserver'? `
  1. Input: python manage.py makemgrations Expected Output: ` Unknown command: 'makemgrations'. Did you mean 'makemigrations' or 'migrate'? `
  1. Input: python manage.py foo Expected Output: ` Unknown command: 'foo'. No similar commands found. `
  1. Input: python manage.py runserver Expected Output: ` Running server as expected (no suggestion needed). `
Last edited 5 months ago by Rishav (previous) (diff)

comment:2 by Clifford Gama, 5 months ago

UI/UX: unset

comment:3 by Rishav, 5 months ago

UI/UX: set

in reply to:  2 comment:4 by Rishav, 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:5 by ontowhee, 5 months ago

Would this ticket be considered a duplicate of #36321?

in reply to:  5 comment:6 by Sarah Boyce, 5 months ago

Resolution: duplicate
Status: newclosed

Replying to ontowhee:

Would this ticket be considered a duplicate of #36321?

Yes I agree

Note: See TracTickets for help on using tickets.
Back to Top