【问题标题】:Unable to resolve url. Received error- Reverse for 'satchmo_search' with arguments '()' and keyword arguments '{}' not found无法解析网址。收到错误 - 未找到带有参数“()”和关键字参数“{}”的“satchmo_search”的反向
【发布时间】:2011-02-26 15:14:19
【问题描述】:

我正在按照以下说明安装 Satchmo:http://forum.webfaction.com/viewtopic.php?pid=10579#p10579

当我想检查我的安装时,我收到以下错误:

$ python manage.py satchmo_check
Checking your satchmo configuration.
Using Django version 1.2.5
Using Satchmo version 0.9.2-pre hg-unknown
The following errors were found:
Unable to resolve url. Received error- Reverse for 'satchmo_search' with arguments '()' and keyword arguments '{}' not found.

我的urls.py 看起来像这样:

from django.conf.urls.defaults import *
from satchmo_store.urls import urlpatterns

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^myproject/', include('myproject.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/', include(admin.site.urls)),
)

在命令行上使用reverse函数,我得到:

$ python manage.py shell
Python 2.7.1 (r271:86832, Dec  1 2010, 06:29:57) 
>>> from django.core.urlresolvers import reverse
>>> reverse(satchmo_search)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'satchmo_search' is not defined

我是 Satchmo 和 Django 的新手,因此我们将不胜感激。

【问题讨论】:

    标签: python django satchmo webfaction


    【解决方案1】:

    您正在覆盖您正在导入的网址。

    像这样改变你的 urls.py 文件:

    from django.conf.urls.defaults import *
    from satchmo_store.urls import urlpatterns
    
    urlpatterns += patterns('',
    
        # Your urls go here
    
    )
    

    from django.conf.urls.defaults import *
    from satchmo_store.urls import urlpatterns as satchmo_urls
    
    urlpatterns = patterns('',
    
        # Your urls go here
    
    )
    
    urlpatterns += satchmo_urls
    

    【讨论】:

      猜你喜欢
      • 2016-11-11
      • 2010-12-22
      • 2013-12-07
      • 2013-07-22
      • 2015-08-29
      • 2014-05-29
      • 2013-07-25
      • 2019-11-06
      相关资源
      最近更新 更多