我是靠谱客的博主 玩命麦片,这篇文章主要介绍报错:arguments '()' and keyword arguments '{}'...,现在分享给大家,希望可以做个参考。

为什么会报错呢: 
NoReverseMatch at /depotapp/cart/view/ 
Reverse for 'depotapp.views.logout_view' with arguments '()' and keyword arguments '{}' not found. 

如果把urls.py 的内容迁移到depotapp/urls.py 就可以。但我希望这个urls是整个项目的,不是单个app的




当你使用{% url depotapp.views.login_view %}这样的方式的话,你指明了view的全路径,所以django会去depotapp这个app下找url pattern。我推荐的方法是使用url name,即把url pattern定义如下:

(r'^accounts/login/$', login_view, name = 'login_view'),
(r'^accounts/logout/$', logout_view, name = 'logout_view'), 

{% url login_view %}
{% url logout_view %}

这样的方式不依赖项目结构

最后

以上就是玩命麦片最近收集整理的关于报错:arguments '()' and keyword arguments '{}'...的全部内容,更多相关报错:arguments内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(75)

评论列表共有 0 条评论

立即
投稿
返回
顶部