无法解析URL。收到错误- 找不到'satchmo_search'的反向参数'()'和关键字参数'{}

0 投票
1 回答
701 浏览
提问于 2025-04-16 12:35

我正在按照这些说明安装 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 都很陌生,所以任何帮助都非常感谢。

1 个回答

3

你正在覆盖你导入的网址设置。

把你的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

撰写回答