以下视图应该加载一个页面'learn.html',但它只是出于某种原因返回索引。
def learn(request):
try:
... # everything goes smoothly here, the else clause is evaluated.
else:
return render(request, 'associate/learn.html', {'dataset':model, 'ordered_groups':ordered_groups})
以下是我的网址:
图片\ urls.py:
urlpatterns = patterns('',
url(r'^images/', include('images_app.urls', namespace="images_app")),
url(r'^associate/', include('associate.urls', namespace="associate")),
url(r'^admin/', include(admin.site.urls)),
)
associate \ urls.py 编辑:我不小心写了图片\ urls.py - 现在更正了。
urlpatterns = patterns('',
url(r'^learn/', "associate.views.learn", name='learn'),
url(r'^$', "associate.views.index", name='index'),
)
这是加载正常的索引页面,应该通过单击学习按钮将用户应该重定向到learn.html。但是,索引页面只是重新加载。
准\ index.html的
Choose a dataset
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="{% url 'associate:learn' %}" method="post">
{% csrf_token %}
{% for dataset in datasets %}
<input type="radio" name="dataset" id="dataset{{ forloop.counter }}" value="{{ dataset.id }}" />
<label for="dataset{{ forloop.counter }}">{{ dataset }}</label><br />
{% endfor %}
<input type="submit" value="learn" />
</form>
准\ learn.html
THIS IS THE LEARN PAGE
感谢您的帮助。
答案 0 :(得分:0)
对于app app的urls.py试试这个
urlpatterns = patterns('associate',
url(r'^learn/', "associate.views.learn", name='learn'),
url(r'^$', "associate.views.index", name='index'),
)