Since I've upgraded to Django ver 1.00, I'm suddenly getting the
following error with my ImageFields.
The tag is {{ model.image.url}} and it throws an error if the image
field in the database is null (even if it is set to null in the model)
Am I missing something? Here is the error message being generated.
TemplateSyntaxError at /offer_detail_ver2/1/
Caught an exception while rendering: The 'image' attribute has no file
associated with it.
Original Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\debug.py", line 71, in render_node
result = node.render(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\debug.py", line 87, in render
output = force_unicode(self.filter_expression.resolve(context))
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 535, in resolve
obj = self.var.resolve(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 676, in resolve
value = self._resolve_lookup(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 705, in _resolve_lookup
current = getattr(current, bit)
File "C:\Python25\Lib\site-packages\django-trunk\django\db\models
\fields\files.py", line 58, in _get_url
self._require_file()
File "C:\Python25\Lib\site-packages\django-trunk\django\db\models
\fields\files.py", line 43, 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.
Request Method: GET
Request URL:
http://localhost/offer_detail_ver2/1/
Exception Type: TemplateSyntaxError
Exception Value:
Caught an exception while rendering: The 'image' attribute has no file
associated with it.
Original Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\debug.py", line 71, in render_node
result = node.render(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\debug.py", line 87, in render
output = force_unicode(self.filter_expression.resolve(context))
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 535, in resolve
obj = self.var.resolve(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 676, in resolve
value = self._resolve_lookup(context)
File "C:\Python25\Lib\site-packages\django-trunk\django\template
\__init__.py", line 705, in _resolve_lookup
current = getattr(current, bit)
File "C:\Python25\Lib\site-packages\django-trunk\django\db\models
\fields\files.py", line 58, in _get_url
self._require_file()
File "C:\Python25\Lib\site-packages\django-trunk\django\db\models
\fields\files.py", line 43, 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.
C:\Python25\Lib\site-packages\django-trunk\django\template\debug.py in
render_node
74. e.source = node.source
75. raise
76. except Exception, e:
77. from sys import exc_info
78. wrapped = TemplateSyntaxError(u'Caught an exception while
rendering: %s' % force_unicode(e, errors='replace'))
79. wrapped.source = node.source
80. wrapped.exc_info = exc_info()
81. raise wrapped # error highlighted on this line
82. return result
83.
84. class DebugVariableNode(VariableNode):
85. def render(self, context):
86. try:
87. output = force_unicode(self.filter_expression.resolve(context))