python--从入门到实践第19章(NoReverseMatch)

本文详细解析了在Python web开发中遇到的NoReverseMatch错误,特别是在处理URL反向解析时的问题。通过实例分析,深入理解该错误产生的原因,并提供了解决方案。
摘要由CSDN通过智能技术生成

NoReverseMatch at /new_entry/3/

Reverse for 'topic' with arguments '('',)' not found. 1 pattern(s) tried: ['topics/(?P<topic_id>\\d+)/$']
Request Method: GET
Request URL: http://localhost:8000/new_entry/3/
Django Version: 2.0.6
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'topic' with arguments '('',)' not found. 1 pattern(s) tried: ['topics/(?P<topic_id>\\d+)/$']
Exception Location: D:\PyCharm\pycharm50\.idea\learning_log\ll_env\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 636
Python Executable: D:\PyCharm\pycharm50\.idea\learning_log\ll_env\Scripts\python.exe
Python Version: 3.6.4
Python Path:
['D:\\PyCharm\\pycharm50\\.idea\\learning_log',
 'D:\\PyCharm\\pycharm50\\.idea\\learning_log\\ll_env\\Scripts\\python36.zip',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
 'C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32',
 'D:\\PyCharm\\pycharm50\\.idea\\learning_log\\ll_env',
 'D:\\PyCharm\\pycharm50\\.idea\\learning_log\\ll_env\\lib\\site-packages']
Server time: Mon, 2 Jul 2018 09:30:24 +0000

源代码:

from django.shortcuts import render
from .models import Topic
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值