from django.urls import path from . import views app_name = 'patients' urlpatterns = [ path('', views.index, name='index'), ]
The actual URL pattern is a call to the path() function, which takes three arguments:
- The first argument is a string that helps Django route the current request properly. Django receives the requested URL and tries to route the request to a view. It does this by searching all the URL patterns we’ve defined to find one that matches the current request. Django ignores the base URL for the project (http://localhost:8000/), so the empty string ('') matches the base URL.
- The second argument in path() z specifies which function to call in views.py. When a requested URL matches the pattern we’re defining, Django calls the index() function from views.py
- The third argument provides the name index for this URL pattern so we can refer to it in other code sections. Whenever we want to provide a link to the home page, we’ll use this name instead of writing out a URL.
from django.contrib import admin from .models import Patient, Symptom admin.site.register(Patient) admin.site.register(Symptom)