1π
Iβm not sure whether Iβve missed something.
Yes : reading the error message β which tells you what the error is -, the traceback β which tells you where the error happened β and then re-reading your code. So you have:
Exception Type: TypeError
Exception Value:
cannot concatenate βstrβ and βintβ objects
Which means you tried to concatenate a string and an integer (which Python does not allow for a quite obvious reason).
and
Exception Location: /home/michel/django/upload/index/views.py in handle_uploaded_file, line 32
which means the error is in /home/michel/django/upload/index/views.py at line 32.
Line 32 of /home/michel/django/upload/index/views.py is :
with open('/home/michel/django/upload/media/file' + count, 'wb+') as destination:
Obviously, '/home/michel/django/upload/media/file' + count
is the culprit. Now you just have to fix this, either making a string of count
or using string formating β both explained in the FineManual(tm).
While youβre at it, you may also want to read about the builtin enumate(sequence)
function.
1π
It concatenate error,you cannot concatenate βstrβ and βintβ objects.
I thinks problem is at this line
'/home/michel/django/upload/media/file' + count
Solution
'/home/michel/django/upload/media/file' + str(count)
Example:
a = 'test'
b = 1
c = a+b
Type Error: cannot concatenate 'str' and 'int' objects
solution:
a = 'test'
b = str(1) or '1'
c = a+b(works fine)
- [Answered ]-Django, DRF Token authentication doesn't work, get Anonymous User
- [Answered ]-Django executing backward relation query occurred a maximum recursion depth exceeded error when I use Manager
- [Answered ]-NoReverseMatch at Django
- [Answered ]-How to remove label?