I have a project named myappointments, which has two apps, clinic and
appointments. As of now, I am using the following urls in clinic.urls:

path('newclinic', views.newclinic, name="newclinic"),
path('<str:cliniclabel>/', views.clinic_home, name="clinic_home"),
path('<str:cliniclabel>/doctors', views.doctorlist, name="doctorlist"),
path('permissions', views.set_perms, name="set_perms"),

So I can access a url mysite.com/clinic/newclinic and
mysite.com/clinic/otherclinic/doctors
I want to call a view in clinic when a direct url is called.
Eg. When I visit mysite.com/newclinic and mysite.com/otherclinic/doctors, I
need the clinic.view to be called at the appropriate function.
I tried the following in myappointments.urls:

urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('appointments.urls')),
path('newclinic', clinic.views.newclinic, name="newclinic"),
path('<str:cliniclabel>/', clinic.views.clinic_home, name="clinic_home"),
path('<str:cliniclabel>/doctors', clinic.views.doctorlist, name="doctorlist"
),
path('permissions', clinic.views.set_perms, name="clinic_set_perms"),
]

But I get the error:
  File "/home/joel/myappointments/myappointments/urls.py", line 24, in
<module>
    path('newclinic', clinic.views.newclinic, name="newclinic"),
NameError: name 'clinic' is not defined

I also tried within myappointments.urls:
urlpatterns = [
path('admin/', admin.site.urls),
path('appointments/', include('appointments.urls')),
path('clinic/', include('clinic.urls')),
path('', include('appointments.urls')),
path('newclinic', include('clinic.urls')),
path('<str:cliniclabel>/', include('clinic.urls')),
path('<str:cliniclabel>/doctors', include('clinic.urls')),
path('permissions', include('clinic.urls')),
]

But that caused some weird behavior.
What's the proper way to do this?
Sincerely yours,

Joel G Mathew

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA%3Diw_8_8CAA4J7T%2Bx%3DZRXgxeqG%2BbxM3AnJsGi6oU%3DicW8rygw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to