Answer the question
In order to leave comments, you need to log in
Django filename with cyrillic?
Actually the problem is, I can’t upload a file containing Cyrillic in the name through the admin panel, I do this:
def make_upload_path(instance, filename):
return u'instructions/%s' % smart_str(filename)
class File(models.Model):
...
file = models.FileField(upload_to=make_upload_path)
def __unicode__(self):
return self.name
Answer the question
In order to leave comments, you need to log in
In general, probably the most correct option would be:
1. Leave
def make_upload_path(instance, filename):
return u'instructions/%s' % filename
Somewhere he encodes your unicode name in ascii, feed him a regular string:
def make_upload_path(instance, filename):
return (u'instructions/%s' % filename).encode('utf-8')
If under Windows look mime with Cyrillic stackoverflow.com/questions/4237898/unicodedecodeerror-ascii-codec-cant-decode-byte-0xe0-in-position-0-ordinal
It becomes interesting why it does not start from the config /etc/supervisor/conf.d/transactions.conf
/home/user/www/transactions/env/bin/python /home/user/www/transactions/manage.py run_gunicorn -- bind=localhost:8000 --log-file /home/user/www/transactions/logs/gunicorn_error.log
and if you just execute this line, then everything is ok. but it won’t work there, you need it to start itself through the supervisor (installed)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question