Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#8372 closed (worksforme)

Exception when form validation fails and uploading an image

Reported by: Jason Zylks Owned by: nobody
Component: contrib.admin Version: 1.0-alpha
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Received the following TemplateSyntaxError:

Caught an exception while rendering: 'InMemoryUploadedFile' object has no attribute 'url'

This happens when uploading an image on the admin site and validation fails on another field. Image upload succeeds if all other fields are valid.


class Person(models.Model):
  name = models.CharField(max_length=50)
  picture = models.ImageField(upload_to='pictures')


If adding a Person in the admin interface, leaving 'name' blank but uploading a file will cause the exception. Repeating with the same image file and a value in the name field will succeed.

More details from debug:

Exception Type: TemplateSyntaxError

Exception Value: Caught an exception while rendering: 'InMemoryUploadedFile' object has no attribute 'url' Original Traceback (most recent call last): File "/usr/local/lib64/python2.5/site-packages/django/template/", line 71, in render_node result = node.render(context) File "/usr/local/lib64/python2.5/site-packages/django/template/", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/usr/local/lib64/python2.5/site-packages/django/utils/", line 49, in force_unicode s = unicode(s) File "/usr/local/lib64/python2.5/site-packages/django/forms/", line 311, in unicode return self.as_widget() File "/usr/local/lib64/python2.5/site-packages/django/forms/", line 339, in as_widget return widget.render(self.html_name, data, attrs=attrs) File "/usr/local/lib64/python2.5/site-packages/django/contrib/admin/", line 89, in render (_('Currently:'), value.url, value, _('Change:'))) AttributeError: 'InMemoryUploadedFile' object has no attribute 'url'

Exception Location: /usr/local/lib64/python2.5/site-packages/django/template/ in render_node, line 81

Python Executable: /usr/bin/python

Python Version: 2.5.0

Change History (2)

comment:1 Changed 10 years ago by Jason Zylks

Resolution: worksforme
Status: newclosed

Downloaded 1.0 beta 1 and the problem seems to be fixed.

comment:2 Changed 10 years ago by

In case anyone wonders, this was fixed in [8277].

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