2
votes

Updates: Thanks for Udi's recommendation, i turned on debug and updated the error message plus my model

Here is my model:

class booktitle(models.Model):
    added_by = models.ForeignKey(User)
    book_title_zh = models.CharField(max_length=255)
    book_desc_zh = models.TextField(blank=True, null=True)
    author_zh = models.CharField(max_length=255)
    publisher_zh = models.CharField(max_length=255)
    category = models.ForeignKey(category)
    cover_img = models.ImageField(upload_to='books/book_img_cover', blank=True, null=True)
    last_updated = models.DateField(auto_now=True)
    date_added = models.DateField(auto_now=True)

    class Meta:
        ordering = ('-date_added',)
        verbose_name = 'Book : 書本'
        verbose_name_plural = 'Book : 書本'

I have a standard django installation. When i use it to upload filename with Chinese Characters, it shows the following error:

UnicodeEncodeError at /admin/booksfair/booktitle/6/ 'ascii' codec can't encode characters in position 51-53: ordinal not in range(128) Request Method: POST Request URL: http://www.mydomain.com/admin/booksfair/booktitle/6/ Django Version: 1.4 pre-alpha SVN-16395 Exception Type: UnicodeEncodeError Exception Value: 'ascii' codec can't encode characters in position 51-53: ordinal not in range(128) Exception Location: /usr/lib/python2.6/genericpath.py in exists, line 18 Python Executable: /usr/bin/python Python Version: 2.6.7 Python Path:
['/usr/lib/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/PIL', '/usr/lib/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/var/www', '/var/www/html/django/website', '/var/www/html/django']

I have found some resolution here, but it doesn't work for my case, this is not a duplicated post. Thank you.

1

1 Answers

0
votes

Your error messages are not useful because of incorrect settings.

(Since you should get a very different error message, please post your problem with the new error message again in a new question instead of updating this one. Thanks.)