这可能是迁移到 django.urls.path() 时的疏忽
This was likely an oversight when migrating to django.urls.path()
大家好,我是这个 django 的新手,我遇到过这种类型的错误
enter image description here
虽然这是我的 url.py
from unicodedata import name
from django.urls import path
from Project.views import viewAppointment, addDiagnosis
from . import views
app_name = "Project"
urlpatterns = [
path('', views.index , name='index'),
path('counter', views.counter, name='counter'),
path('Register', views.Register, name= 'Register'),
path('login', views.login, name='login'),
path('logout', views.logout, name = 'logout'),
path('post/<str:pk>', views.post, name = 'post'),
path('profile', views.profile, name='profile'),
path(r'^appointment/appointment=(?P<appointment_id>[0-
100]+)', viewAppointment,
name='appointment'),
path(r'^appointment/appointment=(?P<appointment_id>[0-
100]+)/AddDiagnonsis',
addDiagnosis,
name='AddDiagnosis')
]
同时这是我的 views.py
def viewAppointment(request, appointment_id):
appointment = Appointment.objects.filter(id=appointment_id)
return render(request, 'appointment_form.html',
{'Appointment': appointment})
def addDiagnosis(request):
return True
您收到系统错误,请执行此操作:
仅更改此并尝试
import django.urls import re_path
urlpatterns = [
re_path(r'^appointment/appointment=(?P<appointment_id>[0-100]+)',viewAppointment, name='appointment'),
re_path(r'^appointment/appointment=(?P<appointment_id>[0-100]+)/AddDiagnonsis', addDiagnosis,name='AddDiagnosis')
]
大家好,我是这个 django 的新手,我遇到过这种类型的错误
enter image description here
虽然这是我的 url.py
from unicodedata import name
from django.urls import path
from Project.views import viewAppointment, addDiagnosis
from . import views
app_name = "Project"
urlpatterns = [
path('', views.index , name='index'),
path('counter', views.counter, name='counter'),
path('Register', views.Register, name= 'Register'),
path('login', views.login, name='login'),
path('logout', views.logout, name = 'logout'),
path('post/<str:pk>', views.post, name = 'post'),
path('profile', views.profile, name='profile'),
path(r'^appointment/appointment=(?P<appointment_id>[0-
100]+)', viewAppointment,
name='appointment'),
path(r'^appointment/appointment=(?P<appointment_id>[0-
100]+)/AddDiagnonsis',
addDiagnosis,
name='AddDiagnosis')
]
同时这是我的 views.py
def viewAppointment(request, appointment_id):
appointment = Appointment.objects.filter(id=appointment_id)
return render(request, 'appointment_form.html',
{'Appointment': appointment})
def addDiagnosis(request):
return True
您收到系统错误,请执行此操作:
仅更改此并尝试
import django.urls import re_path
urlpatterns = [
re_path(r'^appointment/appointment=(?P<appointment_id>[0-100]+)',viewAppointment, name='appointment'),
re_path(r'^appointment/appointment=(?P<appointment_id>[0-100]+)/AddDiagnonsis', addDiagnosis,name='AddDiagnosis')
]