Locked lesson.
About this lesson
To create a web page with Django, there are three important pieces: the view, the template file, and the URL. In this lesson, we'll discuss how URLs work and how to create them within your project.
Exercise files
Download this lesson’s related exercise files.
URLs.docx57.3 KB URLs - Solution.docx
58.3 KB
Quick reference
URLs
Each web page of our app needs its own url. We define those urls in the urls.py file.
When to use
Anytime you create a webpage, you'll need to designate its url in your urls.py file.
Instructions
Modify your original urls.py file to this:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('resume.urls')),
path('admin/', admin.site.urls),
]
Then create a new urls.py file inside of your resume directory. Modify it to this:
from django.urls import path
from . import views
urlpatterns = [
path('', views.home, name="home"),
]
Don't forget to add your resume app to your settings.py fil in the "Installed_Apps" section.
Hints & tips
- Your Django project should have two urls.py files
- One goes in your main directory, the other goes in your resume directory
- Every webpage of your site needs a URL that you designate in the urls.py file in your app folder.
Lesson notes are only available for subscribers.