我试图通过在网络浏览器中粘贴网址http://127.0.0.1:8000/upload_results/UniEX_HG1_A15
来在views.py中调用函数,
但是请求失败,并且我看不到为什么我的URL模式不起作用。
错误:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/upload_results/UniEX_HG1_A15
Using the URLconf defined in varview.urls, Django tried these URL patterns, in this order:
^$ [name='show_index']
^admin/
^upload/ [name='varview_submission']
^upload_results/(?P<project_id>[0-9A-Za-z_]+)/ [name='varview_upload_results']
^validate/(?P<project_id>[0-9A-Za-z_]+)/ [name='varview_validate']
^filterallprojects/[0-9A-Za-z_]+ [name='varview_filterallprojects']
^project/(?P<project_id>[0-9A-Za-z_]+)/wgsmetrics/ [name='varview_wgsmetrics']
^project/(?P<project_id>[0-9A-Za-z_]+)/targetgenecoverage/ [name='varview_targetgenecoverage']
^project/(?P<project_id>[0-9A-Za-z_]+)/(?P<display_option>[0-9A-Za-z_]+)/ [name='varview_project']
^media\/(?P<path>.*)$
The current path, upload_results/UniEX_HG1_A15, didn't match any of these.
这是我的urls.py:
from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib import admin
from varview import views
from varview.forms import DataUploaderForm1, DataUploaderForm2, GetProjectIdForm
urlpatterns = [
url(r'^$', views.show_index, name='show_index'),
url(r'^admin/', admin.site.urls),
url(r'^upload/', views.init_submission, name='varview_submission'),
url(r'^upload_results/(?P<project_id>[0-9A-Za-z_]+)/', views.upload_results, name='varview_upload_results'),
]
这已经有一段时间了,但是与此同时我做了很多更改。 最新更改是包括芹菜(djcelery)。 索引页和其他页面仍然有效。我已经阅读了许多与django-url相关的帖子,但无法弄清楚。
谢谢您的帮助。
答案 0 :(得分:1)
请注意,您的网址后有一个斜杠
^upload_results/(?P<project_id>[0-9A-Za-z_]+)/
但是您正在尝试访问不带斜杠的URL
/upload_results/UniEX_HG1_A15
通常,Django将使用斜杠重定向到URL。也许您的MIDDLEWARE
设置不正确,或者您已将APPEND_SLASH
设置为False
。