Opened 8 years ago

Closed 8 years ago

#28325 closed Bug (needsinfo)

ImageFile extesion validation fails with: AttributeError: 'list' object has no attribute 'name'

Reported by: Maximilian Kindshofer Owned by: nobody
Component: File uploads/storage Version: 1.11
Severity: Normal 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 (last modified by Tim Graham)

I upgraded from 1.11 from 1.10 and I get following error

AttributeError: 'list' object has no attribute 'name'
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "auftragsverwaltung/views.py", line 292, in bilddokumentation_form
    if formset.is_valid():
  File "django/forms/formsets.py", line 321, in is_valid
    self.errors
  File "django/forms/formsets.py", line 295, in errors
    self.full_clean()
  File "django/forms/formsets.py", line 348, in full_clean
    self._errors.append(form.errors)
  File "django/forms/forms.py", line 175, in errors
    self.full_clean()
  File "django/forms/forms.py", line 386, in full_clean
    self._post_clean()
  File "django/forms/models.py", line 396, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
  File "django/db/models/base.py", line 1226, in full_clean
    self.clean_fields(exclude=exclude)
  File "django/db/models/base.py", line 1268, in clean_fields
    setattr(self, f.attname, f.clean(raw_value, self))
  File "django/db/models/fields/__init__.py", line 603, in clean
    self.run_validators(value)
  File "django/db/models/fields/__init__.py", line 555, in run_validators
    v(value)
  File "django/core/validators.py", line 476, in __call__
    extension = os.path.splitext(value.name)[1][1:].lower()

self:	
<django.core.validators.FileExtensionValidator object at 0x7fee879c6828>
value:	
[
<InMemoryUploadedFile: 20170619_150207.jpg (image/jpeg)>
]

Change History (2)

comment:1 by Tim Graham, 8 years ago

Description: modified (diff)

Could you please give steps to reproduce the problem?

comment:2 by Tim Graham, 8 years ago

Resolution: needsinfo
Status: newclosed

You should also confirm that the problem exists in Django 1.11.2 as that moved the ImageField file extension validation added in Django 1.11 from the model field to the form field (#28242). Looking at the traceback, it appears you're using Django 1.11 or 1.11.1.

Please reopen if you can provide steps to reproduce that demonstrates an issue in Django and not an issue in a third-party package, for example.

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