/ items / join()参数处的TypeError必须是str,字节或os.PathLike对象,而不是'dict'

伊恩·萨普特拉

请帮忙,我尝试通过删除代码的一部分并将其放回去来追溯我的代码,以查看是哪一个引发了错误,而这是引发上述错误的那一部分。

context = {
    'items': 'Item.objects.all()'
}

这是从我的django视图

from django.shortcuts import render
from .models import Item

def vendors(request):
    return render(request, 'pages/vendors.html', {'title': 'Vendors'})

def items(request):
    context = {
        'items': Item.objects.all()
    }
    return render(request, context, 'pages/items.html', {'title': 'Items'})

def request(request):
    return render(request, 'pages/request.html', {'title': 'Request'})

这是我尝试访问的项目页面。

{% extends "pages/base.html" %}
{% load humanize %}

{% block content %}
    {% for item in items %}
    <article class="media content-section">
    <div class="media-body">
        <div class="article-metadata">
        <a class="mr-2" href="#">{{ item.requester }}</a>
        <small class="text-muted">{{ item.date_requesteded|naturaltime }}</small>
        </div>
        <h2><a class="article-title" href="#">{{ item.name }}</a></h2>
        <p class="article-content">{{ item.description }}</p>
    </div>
    </article>
    {% endfor %}
{% endblock content %}

另一个html页面工作正常。

亚历山大·列孔采夫(Alexander Lekontsev)
context = {
    'items': Item.objects.all(),
    'title': 'Items'
}
return render(request, 'pages/items.html', context)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Pygame TypeError:join()参数必须是str,bytes或os.PathLike对象,而不是'Surface'

来自分类Dev

TypeError:join()参数必须是str或字节,而不是'PosixPath'

来自分类Dev

Python TypeError:预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

来自分类Dev

代码错误:TypeError:预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

来自分类Dev

TypeError:预期的str,字节或os.PathLike对象,而不是int;在subprocess.run()中

来自分类Dev

pyqtdeploy:TypeError:预期的str,字节或os.PathLike对象,而不是NoneType

来自分类Dev

TypeError:预期的str,字节或os.PathLike对象,而不是元组。怎么解决?

来自分类Dev

TypeError:使用open()打开文件时,预期的str,字节或os.PathLike对象,而不是TextIOWrapper

来自分类Dev

预期的 str、bytes 或 os.PathLike 对象,而不是列表

来自分类Dev

TypeError:int()参数必须是字符串,类似字节的对象或数字,而不是在Django中创建令牌时的“ dict”

来自分类Dev

预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

来自分类Dev

使用 Magpie+Tensorflow/Python3 的“TypeError:join() 参数必须是 str 或字节,而不是 'NoneType'”

来自分类Dev

如何解决错误:Python FTP中的“预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper”

来自分类Dev

类型错误:预期的 str、bytes 或 os.PathLike 对象,而不是元组

来自分类Dev

python中的数据增强抛出错误“int()参数必须是字符串、类似字节的对象或数字,而不是'dict'”

来自分类Dev

TypeError:列表索引必须是整数,而不是dict

来自分类Dev

dict_items对象没有属性“ sort”

来自分类Dev

TypeError:无法连接“ str”和“ dict”对象

来自分类Dev

TypeError:字符串索引必须是整数,而不是str //使用dict

来自分类Dev

TypeError:必须为str,而不是字节Error

来自分类Dev

字典迭代-dict与dict.items()

来自分类Dev

Why is the order of dict and dict.items() different?

来自分类Dev

Django-TypeError:int()参数必须是字符串或数字,而不是'dict'

来自分类Dev

为什么在删除组件时出现TypeError:undefined不是对象(评估“ items.items.map”)?

来自分类Dev

TypeError:file()参数1必须是不带NULL字节的编码字符串,而不是str odoo

来自分类Dev

TypeError:write()参数必须为str,而不是字节,UTF-16

来自分类Dev

尝试将 ElementTree 写入 XML 文件时出现“TypeError:write() 参数必须是 str,而不是字节”

来自分类Dev

如何创建类似dict的对象,该对象通过items()返回重复的值

来自分类Dev

传递有时为参数而不是参数对象的复杂dict是更好的做法吗?

Related 相关文章

  1. 1

    Pygame TypeError:join()参数必须是str,bytes或os.PathLike对象,而不是'Surface'

  2. 2

    TypeError:join()参数必须是str或字节,而不是'PosixPath'

  3. 3

    Python TypeError:预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

  4. 4

    代码错误:TypeError:预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

  5. 5

    TypeError:预期的str,字节或os.PathLike对象,而不是int;在subprocess.run()中

  6. 6

    pyqtdeploy:TypeError:预期的str,字节或os.PathLike对象,而不是NoneType

  7. 7

    TypeError:预期的str,字节或os.PathLike对象,而不是元组。怎么解决?

  8. 8

    TypeError:使用open()打开文件时,预期的str,字节或os.PathLike对象,而不是TextIOWrapper

  9. 9

    预期的 str、bytes 或 os.PathLike 对象,而不是列表

  10. 10

    TypeError:int()参数必须是字符串,类似字节的对象或数字,而不是在Django中创建令牌时的“ dict”

  11. 11

    预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper

  12. 12

    使用 Magpie+Tensorflow/Python3 的“TypeError:join() 参数必须是 str 或字节,而不是 'NoneType'”

  13. 13

    如何解决错误:Python FTP中的“预期的str,字节或os.PathLike对象,而不是_io.TextIOWrapper”

  14. 14

    类型错误:预期的 str、bytes 或 os.PathLike 对象,而不是元组

  15. 15

    python中的数据增强抛出错误“int()参数必须是字符串、类似字节的对象或数字,而不是'dict'”

  16. 16

    TypeError:列表索引必须是整数,而不是dict

  17. 17

    dict_items对象没有属性“ sort”

  18. 18

    TypeError:无法连接“ str”和“ dict”对象

  19. 19

    TypeError:字符串索引必须是整数,而不是str //使用dict

  20. 20

    TypeError:必须为str,而不是字节Error

  21. 21

    字典迭代-dict与dict.items()

  22. 22

    Why is the order of dict and dict.items() different?

  23. 23

    Django-TypeError:int()参数必须是字符串或数字,而不是'dict'

  24. 24

    为什么在删除组件时出现TypeError:undefined不是对象(评估“ items.items.map”)?

  25. 25

    TypeError:file()参数1必须是不带NULL字节的编码字符串,而不是str odoo

  26. 26

    TypeError:write()参数必须为str,而不是字节,UTF-16

  27. 27

    尝试将 ElementTree 写入 XML 文件时出现“TypeError:write() 参数必须是 str,而不是字节”

  28. 28

    如何创建类似dict的对象,该对象通过items()返回重复的值

  29. 29

    传递有时为参数而不是参数对象的复杂dict是更好的做法吗?

热门标签

归档