Opened 19 years ago

Last modified 19 years ago

#1608 closed defect

When using a non existent field as part of a models representation django throws a TemplateSyntaxError — at Initial Version

Reported by: info@… Owned by: Adrian Holovaty
Component: Core (Other) Version: 0.91
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using this model:

class Product(meta.Model):

travelCode = meta.CharField('Reiscode', maxlength=7, primary_key=True)

class Unit(meta.Model):

travelCode = meta.ForeignKey(Product)

def repr(self):

return "%s %s" % (self.get_travelCode(), self.nonexistentfield)

class META:

admin = meta.Admin()

Displaying Unit in the admin interface works for the Unit overview, even though self.nonexistentfield does not exist. When one selects an entry for editting, Django throws the following TemplateSyntaxError:


Traceback (most recent call last):

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/servers/basehttp.py", line 272, in run

self.result = application(self.environ, self.start_response)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/servers/basehttp.py", line 615, in call

return self.application(environ, start_response)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/wsgi.py", line 155, in call

response = self.get_response(request.path, request)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/base.py", line 109, in get_response

return self.get_technical_error_response(request)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/handlers/base.py", line 139, in get_technical_error_response

return debug.technical_500_response(request, *sys.exc_info())

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/views/debug.py", line 126, in technical_500_response

return HttpResponseServerError(t.render(c), mimetype='text/html')

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/init.py", line 146, in render

return self.nodelist.render(context)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/init.py", line 707, in render

bits.append(self.render_node(node, context))

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/init.py", line 725, in render_node

result = node.render(context)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/defaulttags.py", line 112, in render

nodelist.append(node.render(context))

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/defaulttags.py", line 179, in render

return self.nodelist_true.render(context)

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/init.py", line 707, in render

bits.append(self.render_node(node, context))

File "/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/template/init.py", line 735, in render_node

raise wrapped

TemplateSyntaxError: Caught an exception while rendering.


On the front end a similar error is thrown when one tries to use the model object's representation. The error is especially unclear because it refers to a Template error while this essentially is a model error. A model exception stating that the model does not contain such a field would be nicer.

Change History (0)

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