模板渲染期间发生的错误:
在模板/Users/mac/myfirstproject/templates/base_layout.html中,第12行出现错误 找不到“列表”的反面。 “列表”不是有效的视图函数或模式名称。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ARTICLES</title>
<link rel="stylesheet" href="{% static 'styles.css' %}">
</head>
<body>
<div class="wrapper">
<h1><a href="{% url 'list' %}"><img src="{% static 'logo.png' %} "/></a></h1>
{% block content %}
{% endblock %}
</div>>
</body>
</html>
答案 0 :(得分:0)
如上述Andrei的评论所述,您需要确保已在urls.py文件中将“列表”设置为有效的网址名称。
类似这样的东西:
urls.py
select distinct u.users_id, users.name
from users_courses u, users
where u.users_id in (select distinct users_id from users_courses where courses_id = 2)
and u.courses_id = 1
and users.users_id = u.users_id
要使用from django.conf.urls import url
from .views import list_view
urlpatterns = (
url(r'^list$', list_view, name='list'),
)
模板标记,您必须有一个名为{% url 'url_name' %}
的url,并且如果您将项目分为应用程序,则格式为:
{%url'app_name:url_name'%}。如果您发布urls.py文件,也许我们会有所帮助。