Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python NoReverseMatch at/portal/_Python_Html_Django_Drop Down Menu - Fatal编程技术网

Python NoReverseMatch at/portal/

Python NoReverseMatch at/portal/,python,html,django,drop-down-menu,Python,Html,Django,Drop Down Menu,我继承了一个python/django web应用程序,我正试图在一台新机器上使用它。在机器1(原件)上,每个下拉菜单链接工作正常,不会导致错误。在将web应用程序复制到的计算机2上,一个下拉菜单链接会导致以下错误: Exception Type: NoReverseMatch Exception Value: Reverse for 'account_index' with arguments '()' and keyword arguments '{}' not found. 该错

我继承了一个python/django web应用程序,我正试图在一台新机器上使用它。在机器1(原件)上,每个下拉菜单链接工作正常,不会导致错误。在将web应用程序复制到的计算机2上,一个下拉菜单链接会导致以下错误:

Exception Type:     NoReverseMatch
Exception Value: Reverse for 'account_index' with arguments '()' and keyword arguments '{}' not found.
该错误涉及名为“base site.html”的html模板文件。“客户端”下拉列表的代码与“帐户”下拉列表的代码相同。在机器1上两者都工作,在机器2上,帐户1导致错误。下面的python应用程序摘录显示了与下拉列表相关的代码

用于帐户下拉列表

From base-site.html:  <li><a tabindex="-1" href="{% url 'account_index' %}">Browse</a></li>
From account urls.py:  url(r'^/?$', 'account.views.account_index', name='account_index'),
From base-site.html:  <li><a tabindex="-1" href="{% url 'client_index' %}">Browse</a></li>
From client urls.py:  url(r'^$', 'client.views.client_index', name='client_index'),
来自base-site.html:
  • 从account url.py:url(r'^/?$,'account.views.account_index',name='account_index'),
    用于客户端下拉列表

    From base-site.html:  <li><a tabindex="-1" href="{% url 'account_index' %}">Browse</a></li>
    From account urls.py:  url(r'^/?$', 'account.views.account_index', name='account_index'),
    
    From base-site.html:  <li><a tabindex="-1" href="{% url 'client_index' %}">Browse</a></li>
    From client urls.py:  url(r'^$', 'client.views.client_index', name='client_index'),
    
    来自base-site.html:
  • 从client url.py:url(r'^$','client.views.client_index',name='client_index'),

    有人能提出为什么帐户下拉列表在机器1上有效而在机器2上无效吗?如何解决此问题,使其在两台机器上都能工作?可能是副本中从1到2的.pyc文件吗?

    显示错误的机器正在使用django 1.4,而它需要使用django 1.5。url模板方案在不同版本之间发生了更改,并且不向后兼容(很遗憾)

    另外,在重新启动dev服务器之前删除pyc文件

    find . -name "*pyc" | xargs rm
    

    django的版本是否与这两台机器上的所有其他第三方模块完全相同?至于.pyc,为什么不使用某种源代码控制(svn、hg、git等)进行正常部署,而不是复制整个内容?对我来说,这似乎非常容易出错,效率也很低。Python/Django/Apache等在这两台机器上都是一样的。我们的目标是一个应用程序,一旦安装了apache/python/django等,我们就可以放下应用程序文件夹,让它以最小的努力工作。那么你应该看看fabric,复制和过去的事情是一个非常糟糕的做法。我可以安装、格式化驱动器、安装依赖项,并在大约五分钟内启动并运行一个新的应用程序服务器,只需一个命令行。更多信息请访问:你怎么知道re:django?旧机器是否在python虚拟环境中运行,新机器是否在python虚拟环境中运行,反之亦然?检查.wsgi文件以了解这一点,这将告诉您站点正在查看哪些python可执行文件,因此它是否使用系统python或python虚拟环境。啊,没有。两台机器上都检查了Django版本,并且都报告了1.5.1 final。正如我所说的,同样的代码/python/tools/modules在机器1上工作,但这一部分在机器2上失败。