Opened 4 years ago

Closed 4 years ago

#30753 closed New feature (wontfix)

Add 'Did you mean...' when TemplateDoesNotExist occurs

Reported by: Min ho Kim Owned by: Min ho Kim
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description (last modified by Min ho Kim)

When 'TemplateDoesNotExist' occurs from using {% extends %} or {% include %} with wrong file names,
technical_500.html only tells you that source does not exist.

For example, use of below code...

base.html
{% block content %}
{% endblock %}

home.html
{% extends 'baseX.html' %}
{% block content %}
This is home
{% endblock %}

will give you...

TemplateDoesNotExist at /
baseX.html

I propose we add some informative message to help find the source of error by adding

Did you mean...
/Users/minhokim/Code/Django/djangodev/empty/templates/base.html
/Users/minhokim/Code/Django/djangodev/empty/templates2/baseXX.html

Attachments (3)

Screen Shot 2019-09-03 at 21.53.38.png (167.9 KB) - added by Min ho Kim 4 years ago.
Proposed outcome
Proposed outcome.png (167.9 KB) - added by Min ho Kim 4 years ago.
Proposed outcome multiple templates.png (154.0 KB) - added by Min ho Kim 4 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 4 years ago by Min ho Kim

Owner: changed from nobody to Min ho Kim

Changed 4 years ago by Min ho Kim

Proposed outcome

Changed 4 years ago by Min ho Kim

Attachment: Proposed outcome.png added

comment:2 Changed 4 years ago by Min ho Kim

Description: modified (diff)

Changed 4 years ago by Min ho Kim

comment:3 Changed 4 years ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

You've assigned to yourself so I presume there's a patch incoming? (Super 🙂)

Assuming it's not too complicated, this sounds like a nice addition... — very happy to have a look and see.

Thanks for the input!

comment:4 Changed 4 years ago by Mariusz Felisiak

I'm not sure to be honest. List of templates can be really big and in a consequence difflib.get_close_matches() would be time-consuming. I would prefer to get 500 page quick instead of waiting longer for a hint that may not be really helpful.

comment:5 Changed 4 years ago by Min ho Kim

Thanks felixxm for your input.
If this feature request is not accepted/agreed by two of you, I'm happy to have it closed.

comment:6 Changed 4 years ago by Carlton Gibson

Resolution: wontfix
Status: assignedclosed
Triage Stage: AcceptedUnreviewed

OK, let's close it.

  • Not sure how often folks misspell templates, and...
  • If we have hundreds/thousands of templates, it could be slow, so...
  • We'd need a way of turning it off, which probably isn't worth the complexity.

(If someone wants to show that it's not slow, even with large numbers of templates, then, well, we could think about it then...)

Thanks both.

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