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

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条回答

  • 关注
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗