Skip to content

Commit 178f747

Browse files
committed
Replace space with underscore in links to uploaded files
Where does the space to underscore conversion come from? - Not slugify, as that is not used - Not default_storage, as the url method there only replaces dos-slashes Just using simple string replacement until this is better understood.
1 parent c85c78e commit 178f747

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fileupload/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PictureCreateView(CreateView):
1919
def form_valid(self, form):
2020
self.object = form.save()
2121
f = self.request.FILES.get('file')
22-
data = [{'name': f.name, 'url': settings.MEDIA_URL + "pictures/" + f.name, 'thumbnail_url': settings.MEDIA_URL + "pictures/" + f.name, 'delete_url': reverse('upload-delete', args=[self.object.id]), 'delete_type': "DELETE"}]
22+
data = [{'name': f.name, 'url': settings.MEDIA_URL + "pictures/" + f.name.replace(" ", "_"), 'thumbnail_url': settings.MEDIA_URL + "pictures/" + f.name.replace(" ", "_"), 'delete_url': reverse('upload-delete', args=[self.object.id]), 'delete_type': "DELETE"}]
2323
response = JSONResponse(data, {}, response_mimetype(self.request))
2424
response['Content-Disposition'] = 'inline; filename=files.json'
2525
return response

0 commit comments

Comments
 (0)