django - Django URL 模式已停止匹配
问题描述
我一直在使用专门的会员应用程序(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()
成员/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 模式似乎都失败了。例如:网址:
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 调试会话。只是重新启动,而不是终止和启动挂起到已编辑文件的旧缓存版本。
解决方案
推荐阅读
- android - 当我使用 IndoorAtlas 地图并使用三边测量计算我的位置时,如何将我的 LatLng 从一项活动传递到另一项活动?
- azure-function-app - 在 Azure 函数 Integrate 中动态设置 Blob 路径
- oracle - oracle 19c apex 19.1 openid 连接配置错误 ORA-24247: 网络访问被访问控制列表 (ACL) 拒绝
- javascript - 在 HTML 页面之间共享数据
- android - 如何使用 Android Studio 在功能(外部)模块中为动态功能创建模块
- ios - 如何快速将数据转换为字节数组,然后将字节数组转换为整数
- opencv - OpenCV 持有的内存比它需要的时间长
- java - Java中的特殊文本处理
- flutter - 为什么一旦我向我的 TextEditingController 添加一个侦听器以改变 textSize 时,焦点就停留在 TextField 上?
- python - 根据 DataFrame 列名选择变量