Django

Code

Ticket #8265 (closed: duplicate)

Opened 5 months ago

Last modified 5 months ago

Debug template exception message is confuse

Reported by: marinho Assigned to: nobody
Milestone: Component: Template system
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

When some error happens and the debug page for error 500 is shown with debug informations, the exception value is shown as a H2 element, like this:

Caught an exception while rendering: The 'image' attribute has no file associated with it. Original Traceback (most recent call last): File "../django/django/template/debug.py", line 71, in render_node result = node.render(context) File "../django/django/template/defaulttags.py", line 148, in render nodelist.append(node.render(context)) File "../django/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "../django/django/template/__init__.py", line 518, in resolve obj = self.var.resolve(context) File "../django/django/template/__init__.py", line 659, in resolve value = self._resolve_lookup(context) File "../django/django/template/__init__.py", line 688, in _resolve_lookup current = getattr(current, bit) File "/arquivos/Trabalhos/WN/Cranes/cranes_com/apps/spares/models.py", line 108, in __getattr__ thumbnail = get_image_thumbnail_filename() File "/arquivos/Trabalhos/WN/Cranes/cranes_com/apps/spares/models.py", line 100, in get_image_thumbnail_filename file, ext = os.path.splitext(self.image.path) File "../django/django/db/models/fields/files.py", line 50, in _get_path self._require_file() File "../django/django/db/models/fields/files.py", line 40, in _require_file raise ValueError("The '%s' attribute has no file associated with it." % self.field.name) ValueError: The 'image' attribute has no file associated with it. 

This is VERY confuse and make developer spent some time to find the error message and the file/line where the error occured.

My suggestion is change the H2 tag to PRE, with some CSS changes, so, the line breaks are respected exactly as they are when Python raises the exception.

Attachments

8265.diff (0.7 kB) - added by marinho on 08/12/08 15:48:44.

Change History

08/12/08 15:48:44 changed by marinho

  • attachment 8265.diff added.

08/12/08 15:51:53 changed by mtredinnick

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

This is basically the same as #8178.

08/22/08 20:10:47 changed by

  • milestone deleted.

Milestone 1.0 maybe deleted


Add/Change #8265 (Debug template exception message is confuse)




Change Properties
Action