Django URL模式已停止匹配

时间:2018-09-03 20:13:17

标签: django

我一直在使用专门的会员应用程序(My_Members)来学习python和django。稍微修改后的足迹是:

|-- Billing
|   |-- __init__.py
|   |-- admin.py
|   |-- apps.py
|   |-- models
|   |   |-- __init__.py
|   |   |-- account.py
|   |   |-- fees.py
|   |   `-- payment.py
|   |-- tests.py
|   |-- urls.py
|   |-- views
|   |   |-- __init__.py
|   |   |-- account.py
|   |   `-- fees.py
|   `-- views.py
|-- My_Members
|   |-- __init__.py
|   |-- settings.py
|   |-- urls.py
|   `-- wsgi.py
|-- Manager
|   |-- __init__.py
|   |-- admin.py
|   |-- apps.py
|   |-- models
|   |   |-- __init__.py
|   |   `-- group.py
|   |-- tests.py
|   `-- views
|       |-- __init__.py
|       `-- group.py
|-- Members
|   |-- __init__.py
|   |-- account_adapter.py
|   |-- admin.py
|   |-- apps.py
|   |-- forms
|   |   |-- __init__.py
|   |   |-- profile.py
|   |   `-- student.py
|   |-- models
|   |   |-- __init__.py
|   |   |-- profile.py
|   |   |-- rank.py
|   |   |-- student.py
|   |   `-- title.py
|   |-- urls.py
|   `-- views
|       |-- __init__.py
|       |-- group.py
|       |-- index.py
|       |-- profile.py
|       `-- student.py

urls.py下的My_Members如下:

from django.conf.urls import include
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, re_path

from Members.views import index

urlpatterns = [
    path('accounts/', include('allauth.urls')),
    path('Members/', include('Members.urls')),
    path('Billing/', include('Billing.urls')),
    path('admin/', admin.site.urls),
    re_path(r'^$', index, name='index'),
]

urlpatterns += staticfiles_urlpatterns()

Members / urls.py如下:

from django.urls import path, re_path

from .views import index
from .views import profile
from .views import student

urlpatterns = [
    path('Members/Profile/<uuid:profile_id>/edit', profile.Update.as_view(),
         name="profile-update"),
    path('Members/Profile/<uuid:profile_id>/delete', profile.Delete.as_view(),
         name="profile-delete"),
    path('Members/Profile/create', profile.Create.as_view(),
         name="profile-create"),
    path('Members/Student/<uuid:student_id>/edit', student.Update.as_view(),
         name="student-update"),
    path('Members/Student/<uuid:student_id>/delete', student.Delete.as_view(),
         name="student-delete"),
    path('Members/Student/<uuid:account_id>/create', student.Create.as_view(),
         name="student-create"),
    path('Members/', index, name='index'),
]

而Billing / urls.py是:

from django.urls import path, re_path

from Members.views import index
from .views import account

urlpatterns = [
    path('Billing/Account/<uuid:profile_id>/create', account.Create.as_view(),
         name="account-create"),
    path('Billing/', index, name='index'),
]

“帐单网址”文件是新的。自添加以来,几乎所有其他URL模式似乎都失败了。例如:URL:

Members/Profile/ba73e105-325a-42d2-9476-20402d130189/edit

生成错误:

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/Members/Profile/ba73e105-325a-42d2-9476-20402d130189/edit
Using the URLconf defined in CIAMembers.urls, Django tried these URL patterns, in this order:

accounts/
Members/ Members/Profile/<uuid:profile_id>/edit [name='profile-update']
Members/ Members/Profile/<uuid:profile_id>/delete [name='profile-delete']
Members/ Members/Profile/create [name='profile-create']
Members/ Members/Student/<uuid:student_id>/edit [name='student-update']
Members/ Members/Student/<uuid:student_id>/delete [name='student-delete']
Members/ Members/Student/<uuid:account_id>/create [name='student-create']
Members/ ^$ [name='index']
Members/ Members/ [name='index']
Billing/
admin/
^$
^static\/(?P<path>.*)$
The current path, Members/Profile/ba73e105-325a-42d2-9476-20402d130189/edit, didn't match any of these.

我要定位的路径就在错误报告列表的顶部。我想念什么?

修改

@jchung是正确的。我还忘记了在编辑一堆文件后终止并重新启动PyCharm调试会话。只是重新启动(而不是终止和启动)会挂在已编辑文件的旧缓存版本上。

0 个答案:

没有答案