› Forums › Web Development › HarvardX: CS50W – CS50’s Web Programming with Python and JavaScript › CS50W – Lecture 3 – Django › Django Mini Project: Connecting Project and App URLs (With Initial Code + CS50W Reference)
- This topic is empty.
-
AuthorPosts
-
February 9, 2026 at 1:41 am #6036
In this tutorial, we build the foundation of a simple TODO List app in Django and understand how the project’s
urls.pyconnects with the app’surls.py.This concept is also taught in Harvard’s CS50 Web Programming course (CS50W).
👉 Official CS50W URL:
https://cs50.harvard.edu/web/
✅ Initial Context: What Are We Building?
We are creating a small Django app called
tasksthat will display a TODO list.Before starting, we already have:
✔️ A Django project created
✔️ Django installed
✔️ Virtual environment activated
✔️ Development server runningThis setup follows the same structure taught in CS50W’s Django section.
❓ Q1. How do we create the
tasksapp?Answer:
Run:
python manage.py startapp tasksThis creates:
tasks/With:
admin.py apps.py models.py views.py migrations/This is the standard app structure used in CS50W projects.
❓ Q2. Why must we add
taskstoINSTALLED_APPS?Answer:
Open:
settings.pyAdd:
'tasks',Example:
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tasks', ]This step is required in every Django app, including in CS50W exercises.
❓ Q3. What is the initial project-level
urls.pyfile?Answer:
Edit:
project/urls.pyfrom django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('tasks/', include("tasks.urls")), ]This file works as the main URL controller.
❓ Q4. Why do we use
include("tasks.urls")?Answer:
include()connects the project to the app.It means:
“Send all URLs starting with
tasks/to the tasks app.”This same method is used in CS50W’s
hello,wiki, andcommerceprojects.
❓ Q5. How do we create the app-level
urls.pyfile?Answer:
Create:
tasks/urls.pyAdd:
from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), ]This file maps app URLs to views.
❓ Q6. What is the initial
views.pyfile?Answer:
Edit:
tasks/views.pyfrom django.http import HttpResponse def index(request): return HttpResponse("Welcome to My TODO App")This is your first Django view.
CS50W introduces views in exactly this way.
❓ Q7. How are the two
urls.pyfiles connected?Answer:
They are linked using
include().Project File:
path('tasks/', include("tasks.urls"))App File:
path("", views.index)This creates a routing chain.
❓ Q8. What happens when I visit
/tasks/?Answer:
Request flow:
1️⃣ Browser →
/tasks/
2️⃣ Projecturls.pymatchestasks/
3️⃣ Loadstasks/urls.py
4️⃣ Matches""
5️⃣ Callsindex()
6️⃣ Returns responseResult:
Welcome to My TODO App
❓ Q9. Why is
""used inpath("")?Answer:
It means:
“No URL part remains.”
After removing
tasks/, nothing is left.So:
/tasks/ → ""
❓ Q10. What is the complete initial project structure?
Answer:
myproject/ ├── manage.py ├── myproject/ │ ├── settings.py │ ├── urls.py │ └── wsgi.py └── tasks/ ├── urls.py ├── views.py ├── models.py └── migrations/This structure matches what CS50W teaches.
❓ Q11. What if I add more pages later?
Answer:
Extend
tasks/urls.py:urlpatterns = [ path("", views.index), path("add/", views.add), path("delete/", views.delete), ]Now:
URL View /tasks/ index /tasks/add/ add /tasks/delete/ delete
❓ Q12. Why is this system important in real projects?
Answer:
It provides:
✅ Clean organization
✅ App separation
✅ Easy debugging
✅ Reusability
✅ Professional structureAll major Django projects (including CS50W final projects) use this design.
❓ Q13. How does this relate to CS50W?
Answer:
This routing system is taught in:
📘 CS50’s Web Programming with Python and JavaScript
Official Course Page:
👉 https://cs50.harvard.edu/web/In CS50W, you learn this concept through:
helloprojectwikiprojectcommerceproject- Final project
Your TODO app follows the same professional pattern.
📌 Final Summary (For Readers)
Django uses two
urls.pyfiles.
The project file routes to apps usinginclude().
The app file routes to views.
This system is taught in CS50W and used in real-world Django projects.
-
AuthorPosts
- You must be logged in to reply to this topic.

