qq_34623008 2019-07-27 15:55 采纳率: 0%
浏览 1607

Django在运行时出现Reverse for 'xxx' with no arguments not found.

本人刚学Django,这是一个临时程序,本来想实现通过url查找用户信息,并且在代码片段中添加了跳转链接

urls.py

from . import views
from django.conf.urls import url, include

urlpatterns = [
    url(r'^$',views.index,name='index'),
    url(r'^(?P<name_id>\d+)/$',views.names,name='names'),
]

views.py

from django.shortcuts import render
from .models import Name

# Create your views here.
def index(request):
    name = Name.objects.all()
    context = {'names':name}
    return render(request,'index.html',context)

def names(request, name_id):
    name = Name.objects.get(id=name_id)
    context = {'name':name}
    return render(request,'names.html',context)

index.py

<p>INDEX</p>
<!--这里想通过无序列表将用户名列出来-->
<ul>
    {% for name in names %}
        <!--本来想在此处插入跳转链接的,但是出错-->
        <li><a href="{% url 'testing:names' %}">{{ name }}</a></li>
    {% empty %}
        <li>NOTHING HERE</li>
    {% endfor %}
</ul>

以上就是主要的代码
报错如下:

  • 写回答

1条回答 默认 最新

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog