我一直在尝试在我的 Django 应用程序中实现超链接,其中显示项目列表,单击每个项目将带您进入详细说明有关该项目的更多信息的页面。
我一直在与 {% URL %} 标签搏斗,尽管在这里搜索,互联网和有关此事的书籍,我还没有让它工作。
在views.py中:
def Link(request):
return render_to_response('Search_Page.html')
在 Urls.py 中:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ParkManager.views.home', name='home'),
# url(r'^ParkManager/', include('ParkManager.foo.urls')),
url(r'^test/', Search_Page),
url(r'^search/', Search),
url(r'^details/', Details_Main),
url(r'^Link/(d+}/$', Link),
url(r'^$', 'Parks.views.Link', name="home"),
在我的模板中:
<a href="{% url home %}">test</a>
谢谢你的时间 :)
编辑错误:
页面加载,但是当我添加时,链接仅将您带到 127 .0 .0 .1 /8000:测试
我得到:
NoReverseMatch at /search/
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.
Request Method:
GET
Request URL:
http://127.0.0.1:8000/search/?search=a&type=parks&submit=Search
Django Version:
1.4.2
Exception Type:
NoReverseMatch
Exception Value:
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.
Exception Location:
C:\Python27\lib\site-packages\django\template\defaulttags.py in render, line 424
Python Executable:
C:\Python27\python.exe
Python Version:
2.7.3
Python Path:
['C:\\Users\\User\\Documents\\Django\\ParkManager',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
Server time:
Mon, 4 Feb 2013 16:05:30 +0000
Error during template rendering
In template C:\Users\User\Documents\Django\ParkManager\Templates\Details_Main.html, error at line 23
Reverse for 'name' with arguments '(u'North West Thrill Centre',)' and keyword arguments '{}' not found.