Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
ImageField causing error when rendering with "The Image" attribute has no file associated with it.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mermer  
View profile  
 More options Feb 19 2009, 7:30 am
From: mermer <merme...@googlemail.com>
Date: Thu, 19 Feb 2009 04:30:54 -0800 (PST)
Local: Thurs, Feb 19 2009 7:30 am
Subject: ImageField causing error when rendering with "The Image" attribute has no file associated with it.
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))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mermer  
View profile  
 More options Feb 23 2009, 12:54 pm
From: mermer <merme...@googlemail.com>
Date: Mon, 23 Feb 2009 09:54:32 -0800 (PST)
Local: Mon, Feb 23 2009 12:54 pm
Subject: Re: ImageField causing error when rendering with "The Image" attribute has no file associated with it.
Anybody with any advice on this.  Ever since wev'e upgraded to version
1.00 we are having issues with the ImageField

ValueError: The 'image' attribute has no file associated with it.

On 19 Feb, 12:30, mermer <merme...@googlemail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karen Tracey  
View profile  
 More options Feb 23 2009, 3:40 pm
From: Karen Tracey <kmtra...@gmail.com>
Date: Mon, 23 Feb 2009 15:40:22 -0500
Local: Mon, Feb 23 2009 3:40 pm
Subject: Re: ImageField causing error when rendering with "The Image" attribute has no file associated with it.

There was some major file storage refactoring done before 1.0, which I'd
guess introduced a requirement that attempting to retrieve the url
associated with a file-type object requires a file to be associated with
that object.  A little experimenting in the shell shows that now where {{
m.file.url }} generates the exception you report in the case where m.file
has no file,

{% if m.file %}{{ m.file.url }}{% endif %}

does not.  I didn't work on the file storage refactor so I don't know if
this was an intentional difference, and I haven't checked if this was
explicitly documented as a backwards-incompatible change, but it seems
not-so-surprising that such a method would require a file to be set, and
easy enough to adjust to?

Karen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »