Opened 16 years ago

Closed 16 years ago

Last modified 16 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: no UI/UX: no

Description

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

Change History (2)

comment:1 by Jason Zylks, 16 years ago

Resolution: worksforme
Status: newclosed

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

comment:2 by , 16 years ago

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

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