Opened 9 years ago
Closed 9 years ago
#26365 closed New feature (fixed)
Add a system check to ensure "string_if_invalid" is a string
Reported by: | JOSEPH KIM | Owned by: | Vincenzo Pandolfo |
---|---|---|---|
Component: | Core (System checks) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
template option "string_if_invalid" cannot find error location with including html
for example
index.html
...
{% include "inc_home.html" %}
...
and inc_home.html has an invalid variable, Dajngo raise error at the beginning of index.html
work fine with {% extends %}
Attachments (1)
Change History (10)
comment:1 by , 9 years ago
by , 9 years ago
Attachment: | template_bug.zip added |
---|
follow-up: 3 comment:2 by , 9 years ago
What version of Django are you using? On Django 1.8.x and Django 1.9.x, the sample project is crashing with:
File "/home/tim/code/django/django/template/base.py", line 1043, in render output = self.filter_expression.resolve(context) File "/home/tim/code/django/django/template/base.py", line 716, in resolve if '%s' in string_if_invalid: TypeError: argument of type 'bool' is not iterable
If I change the value to a string, e.g. 'string_if_invalid': 'fooo',
, I'm seeing that value in the homepage output.
comment:3 by , 9 years ago
Replying to timgraham:
What version of Django are you using? On Django 1.8.x and Django 1.9.x, the sample project is crashing with:
File "/home/tim/code/django/django/template/base.py", line 1043, in render output = self.filter_expression.resolve(context) File "/home/tim/code/django/django/template/base.py", line 716, in resolve if '%s' in string_if_invalid: TypeError: argument of type 'bool' is not iterableIf I change the value to a string, e.g.
'string_if_invalid': 'fooo',
, I'm seeing that value in the homepage output.
1.9.4 and it's intended error. Because, Django raised error but not indicate appropriate location in code if html file is included.
comment:4 by , 9 years ago
Component: | Template system → Core (System checks) |
---|---|
Summary: | template option "string_if_invalid" can't find error location whit including html → Add a system check to ensure "string_if_invalid" is a string |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → New feature |
string_if_invalid
must be a string, not a boolean. We could add a system check to catch this mistake.
comment:5 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 9 years ago
Has patch: | set |
---|
comment:8 by , 9 years ago
Patch needs improvement: | unset |
---|
I can't reproduce this given the information you provided. Could you provide a complete example as a sample project or as a test case for Django's test suite (tests/template_tests)?