推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
inyfee
V2EX  ›  Python

Django admin 后台管理添加了 verbose_name 属性之后 报错,求解决方法

  •  1
     
  •   inyfee · Apr 28, 2014 · 9045 views
    This topic created in 4409 days ago, the information mentioned may be changed or developed.
    为了显示中文 ,在model 中这样设置:
    class BlogModel(models.Model):
    title = models.CharField('标题',max_length=255)

    class Meta:
    verbose_name = "测试"
    verbose_name_plural = "测试"
    app_label = u"新闻编辑"

    显示中文成功 ,但是点击之后出现如下错误 :

    ProgrammingError at /admin/新闻编辑/blogmodel/
    (1146, "Table 'django_db.\xe6\x96\xb0\xe9\x97\xbb\xe7\xbc\x96\xe8\xbe\x91_blogmodel' doesn't exist")
    Request Method: GET
    Request URL: http://localhost/admin/%E6%96%B0%E9%97%BB%E7%BC%96%E8%BE%91/blogmodel/


    注释掉class Meta 则无错误。请问是哪里出问题?

    Django: 1.6.3
    6 replies    2014-04-30 00:27:29 +08:00
    delo
        1
    delo  
       Apr 28, 2014 via iPhone
    model所在的app叫新闻编辑?文件夹结构是怎样的?看看是不是app_label的问题
    cbsw
        2
    cbsw  
       Apr 28, 2014
    之前做过类似的事情,是app_label的问题,把admin整体变成中文似乎比较麻烦,尤其是表。 可参考这篇文章 http://blog.csdn.net/thinkinside/article/details/7255707
    ericls
        4
    ericls  
       Apr 28, 2014
    把app_lable去掉
    inyfee
        5
    inyfee  
    OP
       Apr 28, 2014
    确实是app_label的问题,只能去掉吗? 我需要它显示为中文的
    cloudream
        6
    cloudream  
       Apr 30, 2014   ❤️ 1
    app_label是model定义在models.py文件以外时指定app名的属性,不是用来设定app名称的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2795 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 10:08 · PVG 18:08 · LAX 03:08 · JFK 06:08
    ♥ Do have faith in what you're doing.