Opened 13 years ago
Closed 10 years ago
#16383 closed New feature (fixed)
More specific errors when resolving template Variables
Reported by: | Miguel Araujo | Owned by: | ANUBHAV JOSHI |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | _resolve_lookup, resolve, template, variable, exception |
Cc: | Miguel Araujo, Tim Graham, hirokiky@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When resolving a template variable that calls an object method/property. If that method/property has errors we get a VariableDoesNotExist
exception without what errors happened, which might confuse the user.
My patch raises the same exception, with related error information. I wasn't sure what type of Exception raise and probably the exception message is not the best one.
Attachments (1)
Change History (11)
by , 13 years ago
Attachment: | _resolve_lookup.patch added |
---|
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
I ran into this one today. The patch would fix it for me. I was trying to do {{ form.errors }} (errors is a @property), and my validation code caused an AttributeError. I didn't need to call form.is_valid() in the view.
So, actually, if we know for sure that the object in the context (current) does indeed have that attribute (bit), then we should really just re-raise the original exception.
comment:4 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I will work on this in my GSoC project.
comment:5 by , 10 years ago
Version: | 1.3 → master |
---|
comment:6 by , 10 years ago
Cc: | added |
---|
comment:8 by , 10 years ago
Cc: | added |
---|
this pull-request is focus when some property raise AttributeError
, right?
I just commented about problem on the surface.
comment:9 by , 10 years ago
Yep.
If a property raises AttributeError, so it occured as if property didn't existed...so I checked that.
comment:10 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Overall, I like the idea of raising more specific errors.
See also #6907 and #11421.
It would be useful to discuss the details on django-developers.