I have a django model with a field:
ImageField
When i am saving data in it, its saving successfully. But it changes its name.
Code i am using to save
from django.core.files.base import ContentFile
def save_file(request):
mymodel = MyModel.objects.get(id=1)
file_content = ContentFile(request.FILES['video'].read())
mymodel.video.save(request.FILES['video'].name, file_content)
Now whatever name is in
request.FILES['video'].name
(a random 36 character uid) django just changes its last some character while saving.
Here is field definition.
file_image = models.ImageField(upload_to='some dir path', null=True)
I am using django 1.9 and python 2.7
Example input and output :
if i try to pass this id as an first argument to save it stores in db with a bit different name like this
what i gave :
123e4567-e89b-12d3-a456-426655440000
output saved in db
123e4567-e89b-12d3-a456-426655434353
75% of character remains same but end of id is getting changed