#35658: InMemoryFileNode object has no attribute "name"
-------------------------------------+-------------------------------------
Reporter: David | Owner: Lucas
| Esposito
Type: Bug | Status: new
Component: File | Version: 4.2
uploads/storage |
Severity: Normal | Resolution:
Keywords: storage | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* resolution: worksforme =>
* status: closed => new
Comment:
Ah I found an error
{{{#!python
@override_settings(
STORAGES={"default": {"BACKEND":
"django.core.files.storage.InMemoryStorage"}}
)
class FileFieldModelTest(TestCase):
def test_repr(self):
test = FileFieldModel()
test.file.save(None, ContentFile(b'content', 'myfile.txt'))
self.assertEqual(repr(test.file), "<FieldFile: myfile.txt>")
}}}
Breaks with
{{{
Traceback (most recent call last):
File "test-django-package/mysite/app3/tests.py", line 13, in test_repr
test.file.save(None, ContentFile(b'content', 'myfile.txt'))
File "test-django-package/venv/lib/python3.10/site-
packages/django/db/models/fields/files.py", line 92, in save
name = self.field.generate_filename(self.instance, name)
File "test-django-package/venv/lib/python3.10/site-
packages/django/db/models/fields/files.py", line 335, in generate_filename
filename = posixpath.join(dirname, filename)
File "/usr/lib/python3.10/posixpath.py", line 90, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.10/genericpath.py", line 152, in _check_arg_types
raise TypeError(f'{funcname}() argument must be str, bytes, or '
TypeError: join() argument must be str, bytes, or os.PathLike object, not
'NoneType'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35658#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701912cf7b47a-896190ca-f5d6-440f-91db-35d0b58aff6d-000000%40eu-central-1.amazonses.com.