Django-类型错误匹配查询不存在

时间:2019-03-17 15:30:23

标签: django typeerror

目前正在经历一些非常奇怪的事情。

尽管,我有一个普通的函数和模板,但是我收到一个TypeError,它引用了我views.py中属于不同函数/模板的一行...

views.py:

def shopping(request):
 shops = Shop.objects.all()
 return render(request, 'home/shops.html', {'shops':shops})

shops.html:

{% extends 'base_template.html' %}

{% block content%}

<h2> Welcome </h2>

{{ shops }}

{% endblock%}

错误:

DoesNotExist at /home/shops/

Shop matching query does not exist.
shopdetail = Shop.objects.get(slug=shopslug)  ---> belongs to a different function

0 个答案:

没有答案