Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21107 closed Bug (invalid)

Django Admin doc Chinese description

Reported by: Balicanta Owned by: nobody
Component: contrib.admindocs Version: 1.5
Severity: Normal Keywords: Chinese
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I try to add admin doc in my project , and add some description to model's docstring, but it appear some error, and my description is Chinese

and I think the problem is cause by "contrib/admindocs/templates/admin_doc/model_detail.html line 29" and {% trans description %} , when I

remove the trans, the error will disappear, my question is the description really need trans?

Attachments (1)

螢幕快照 2013-09-16 下午3.10.16.png (122.7 KB) - added by anonymous 3 years ago.

Download all attachments as: .zip

Change History (9)

Changed 3 years ago by anonymous

comment:1 Changed 3 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

I was not able to reproduce your problem. You should give us some minimal code to reproduce the error (and possibly the full traceback of the error).

comment:2 Changed 3 years ago by balicanta

  • Resolution needsinfo deleted
  • Status changed from closed to new

Sorry, if i have a model like

class Song(models.Model):

And that will appear the error , but if I change to

class Song(models.Model):

that admin doc work correctly

comment:3 Changed 3 years ago by claudep

What is the encoding of your file (see preamble at the top of the file)?

comment:4 Changed 3 years ago by Balicanta

# coding: utf-8

Top of the, thanks

comment:5 Changed 3 years ago by timo

  • Triage Stage changed from Unreviewed to Accepted

I can reproduce with the details above, the exception is a DjangoUnicodeDecodeError:

Exception Value: 'ascii' codec can't decode byte 0xe6 in
position 5: ordinal not in range(128). You passed in
<django.utils.functional.__proxy__ object at 0x7fe4f4341b50> (<class 'django.utils.functional.__proxy__'>)

Not sure about the solution, but I don't think simply removing the {% trans %} tag is the correct one.

comment:6 Changed 3 years ago by mjtamlyn

Does making the docstring a Unicode string help?

comment:7 Changed 3 years ago by timo

  • Resolution set to invalid
  • Status changed from new to closed

Yes, that fixes the issue, thanks! So to summarize, this isn't an issue with Django but rather you need to make the docstring a unicode string by prefixing it with a u or using from __future__ import unicode_literals.

comment:8 Changed 3 years ago by claudep

Ah yes, I had the from __future__ import unicode_literals in my test file, that's why I couldn't reproduce.

Note: See TracTickets for help on using tickets.
Back to Top