juliomalegria / django-chunked-upload

Upload large files to Django in multiple chunks, with the ability to resume if the upload is interrupted.
MIT No Attribution
214 stars 71 forks source link

Continually getting AttributeError: 'str' object has no attribute '_meta' #51

Closed nonnimartin closed 4 years ago

nonnimartin commented 4 years ago

Many thanks for your excellent library! I am trying to use it in my own case, but am finding that I am bumping up against an error where I'm hitting a dead end. In my view.py file, I continually am seeing the following error:

Internal Server Error: /upload/chunked_upload Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, *args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, **kwargs) File "/Users/jonathanmartin/git/absFileNav/absFileNav/upload/views.py", line 308, in post return self._post(request, *args, **kwargs) File "/Users/jonathanmartin/git/absFileNav/absFileNav/upload/views.py", line 406, in _post chunked_upload = self.create_chunked_upload(save=False, **attrs) File "/Users/jonathanmartin/git/absFileNav/absFileNav/upload/views.py", line 357, in create_chunked_upload chunked_upload = self.model(**attrs) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/base.py", line 483, in __init__ _setattr(self, field.name, rel_obj) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py", line 205, in __set__ if value is not None and not isinstance(value, self.field.remote_field.model._meta.concrete_model): AttributeError: 'str' object has no attribute '_meta'

The error occurs when I am calling self.model(**attrs). However, the value of my attrs variable is something like the following:

{'filename': 'filename.extension', 'user': <SimpleLazyObject: <function AuthenticationMiddleware.process_request.. at 0x10819f730>>}

Am I missing some attributes in the ChunkedUploadView object? Do you have any pointers for why I'm seeing this error? I am happy to provide more information if you have any time to give me some pointers. Am I supposed to be including the file in memory in my attributes? I have not changed much of the code from your original work.

Thank you again for developing this package and for any advice you might have! I’ve been stuck on this for a while now, and verbose logging isn’t getting me any further.

nonnimartin commented 4 years ago

Never mind, I got it working but never figured out why this was happening. I'll close the issue. Thank you again for this library!