Here a simple django model:
class File(models.Model):
info = models.CharField(max_length=150,null=True,blank=True)
slug = models.SlugField(max_length=50, blank=True)
file = models.FileField(upload_to="files")
and I would like to save any instance so that the file's file name would be a persian file name. this is my view:
class FileCreateView(CreateView):
model = File
def form_valid(self, form):
self.object = form.save()
f = self.request.FILES.get('file')
files = [{
'url': self.object.file.url,
'name': self.object.file.url[6:],
'thumbnailUrl': self.object.file.url,
'info' : self.object.info,
'size': f.size,
'deleteUrl': reverse('upload-delete', args=[self.object.id]),
'deleteType': "DELETE",
}]
data = {"files": files}
response = JSONResponse(data, {}, response_mimetype(self.request))
response['Content-Disposition'] = 'inline; filename=files.json'
return response
but when i want upload a new file with persian name , i get this error in my view:
SyntaxError: Unexpected token
thank u :)