This was likely an oversight when migrating to django.urls.path()

Question:

So hello guys, I am new to this django and i have encountered this type of error

enter image description here

while this if my 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')
      ]   

meanwhile this is my 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 

Answers:

You are getting system error so do this:

change this only and try

from 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')
        ]
Answered By: Manoj Tolagekar
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.