V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2020-02-22 12:01:04 +08:00 · 1543 次点击
    这是一个创建于 1522 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用
    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 条回复    2020-03-08 22:00:34 +08:00
    kidblg
        1
    kidblg  
       2020-02-24 12:03:07 +08:00
    换个查询条件的关键字也查不出来?比如 title 之类的。
    krixaar
        2
    krixaar  
       2020-02-26 09:53:06 +08:00
    盲猜编码问题,看一下 request 传过来的 category_name 对不对
    gxstar123
        3
    gxstar123  
    OP
       2020-03-08 22:00:34 +08:00
    @krixaar 应该是 IIS 对中文支持不太好的原因吧,category__name 是中文,换 apache 试了试就没问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3801 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 10:35 · PVG 18:35 · LAX 03:35 · JFK 06:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.