I wrote a model to hold files uploaded by users, it goes like this:
Model:
class Userfiles(models.Model):
user = models.ForeignKey(
User,
verbose_name="user name",
)
upload_file = models.FileField(
u"file",
upload_to='user/%Y/%m/%d',
)
upload_date = models.DateTimeField(
auto_now=True,
)
and when I try to add an mp3 file with chinese filename through the
admin interface, the files are not saved correctly, their names are
changed to something like: '.mp3', '_.mp3', '__.mp3'.
Has anyone any idea on how to solve this problem? Thanks!
Hi all!
I wrote a model to hold files uploaded by users, it goes like this:
[snip]
and when I try to add an mp3 file with chinese filename through the
admin interface, the files are not saved correctly, their names are
changed to something like: '.mp3', '_.mp3', '__.mp3'.
Has anyone any idea on how to solve this problem? Thanks!
Yeah, I cannot understand why they will substitute all those character
out there too. Anyway, I removed that line from get_valid_filename in
django/utils/text.py and my app is happily running now. However, I got
that hack from this ticket:
http://code.djangoproject.com/ticket/6009
which, I believe, is more instructive.
Thank you again for your help!