推荐学习书目
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
gxstar123
V2EX  ›  Python

请问一下 Django 相同视图函数里的查询代码 runserver 和 IIS 反映出来的结果却不同是怎么回事

  •  
  •   gxstar123 · Feb 22, 2020 · 2004 views
    This topic created in 2283 days ago, the information mentioned may be changed or developed.
    使用
    def categories(request,category_name):
    articleList=Article.objects.filter(category__name=category_name)
    context={
    'articleList':articleList,
    }
    return render(request,'blog/category.html',context)

    通过分类名称查询,使用 django 自带服务器调试完全正常,能够找到想要的结果,自己电脑用 IIS 搭建的服务器却找不到。如果不用 filter 设置查询条件,使用 objects.all 就完全正常,都能带出结果。
    3 replies    2020-03-08 22:00:34 +08:00
    kidblg
        1
    kidblg  
       Feb 24, 2020
    换个查询条件的关键字也查不出来?比如 title 之类的。
    krixaar
        2
    krixaar  
       Feb 26, 2020
    盲猜编码问题,看一下 request 传过来的 category_name 对不对
    gxstar123
        3
    gxstar123  
    OP
       Mar 8, 2020
    @krixaar 应该是 IIS 对中文支持不太好的原因吧,category__name 是中文,换 apache 试了试就没问题
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2941 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 12:38 · PVG 20:38 · LAX 05:38 · JFK 08:38
    ♥ Do have faith in what you're doing.