这里有一个Django/Python新手.我使用的是python 3.4和Django 1.7版本.
我试图让我的索引页面加载超链接,我看到这个问题.
我的index.html(删除不需要的行)
<form action="{% url 'testapp:search' %}" method="get">
{% csrf_token %}
<a href="{% url 'testapp:detail' morphological %}"">Morphological</a>
</form>
Run Code Online (Sandbox Code Playgroud)
urls.py
from django.conf.urls import patterns, url
from testapp import views
urlpatterns = patterns('',
#url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^$', 'testapp.views.index', name='index'),
#url(r'^search-form/$', views.IndexView.as_view(), name='index'),
url(r'^search-form/$', 'testapp.views.index', name='index'),
#url(r'^(?P<pk>\d+)/$', views.DetailView.as_view(), name='detail'),
#url(r'^option=(?P<option>\d+)/$', views.DetailView.as_view(), name='detail'),
url(r'^detail/(?P<val>\w+)/?$', 'testapp.views.detail', name='detail'),
#url(r'^search/$', views.search, name='search'),
url(r'^search/$', views.search, name='search'),
)
Run Code Online (Sandbox Code Playgroud)
views.py
from django.shortcuts import render, get_object_or_404
from django.shortcuts import render_to_response
# Create your views here.
from django.http import …Run Code Online (Sandbox Code Playgroud)