mirror of
https://github.com/Hopiu/django-fobi.git
synced 2026-05-11 06:13:10 +00:00
Merge pull request #8 from thomasWajs/master
Replace system-specific path separator by a slash on file urls
This commit is contained in:
commit
324ef8fe89
1 changed files with 4 additions and 1 deletions
|
|
@ -4,6 +4,8 @@ __copyright__ = 'Copyright (c) 2014 Artur Barseghyan'
|
|||
__license__ = 'GPL 2.0/LGPL 2.1'
|
||||
__all__ = ('FileInputPlugin',)
|
||||
|
||||
import os
|
||||
|
||||
from django.forms.fields import FileField
|
||||
from django.forms.widgets import ClearableFileInput
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
|
@ -56,7 +58,8 @@ class FileInputPlugin(FormFieldPlugin):
|
|||
# Handle the upload
|
||||
saved_file = handle_uploaded_file(FILES_UPLOAD_DIR, file_path)
|
||||
# Overwrite ``cleaned_data`` of the ``form`` with path to moved file.
|
||||
form.cleaned_data[self.data.name] = "{0}{1}".format(settings.MEDIA_URL, saved_file)
|
||||
file_relative_url = saved_file.replace(os.path.sep, '/')
|
||||
form.cleaned_data[self.data.name] = "{0}{1}".format(settings.MEDIA_URL, file_relative_url)
|
||||
|
||||
# It's critically important to return the ``form`` with updated ``cleaned_data``
|
||||
return form
|
||||
|
|
|
|||
Loading…
Reference in a new issue