﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8372	Exception when form validation fails and uploading an image	Jason Zylks	nobody	"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.

Example:

models.py
{{{
...
class Person(models.Model):
  name = models.CharField(max_length=50)
  picture = models.ImageField(upload_to='pictures')
...
}}}

admin.py
{{{
...
admin.site.register(models.Person)
...
}}}

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/debug.py"", line 71, in render_node result = node.render(context) File ""/usr/local/lib64/python2.5/site-packages/django/template/debug.py"", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File ""/usr/local/lib64/python2.5/site-packages/django/utils/encoding.py"", line 49, in force_unicode s = unicode(s) File ""/usr/local/lib64/python2.5/site-packages/django/forms/forms.py"", line 311, in __unicode__ return self.as_widget() File ""/usr/local/lib64/python2.5/site-packages/django/forms/forms.py"", 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/widgets.py"", 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/debug.py in render_node, line 81

Python Executable: /usr/bin/python

Python Version: 2.5.0
"		closed	contrib.admin	1.0-alpha		worksforme			Unreviewed	0	0	0	0	0	0
