› Forums › Web Development › HarvardX: CS50W – CS50’s Web Programming with Python and JavaScript › CS50W – Lecture 3 – Django › Understanding the Difference Between manage.py and settings.py in Django (CS50 Web)
- This topic is empty.
-
AuthorPosts
-
June 18, 2026 at 5:31 am #6907
When starting with Django in the CS50 Web course, two files appear in almost every project:
manage.pysettings.py


Both are essential, but they serve completely different purposes. Understanding their roles makes it much easier to understand how a Django project starts and operates.
The Big Idea
File Purpose manage.pyThe command-line utility used to run Django commands. settings.pyThe configuration file that tells Django how the project should behave. A simple analogy:
manage.py = Driver
settings.py = Map and instructions
Django = CarThe driver tells the car what to do, while the map and instructions tell the car how to operate.
What Is
manage.py?manage.pyis Django’s command center. It allows us to execute administrative commands from the terminal.A typical
manage.pyfile looks like this:#!/usr/bin/env python import os import sys def main(): os.environ.setdefault( 'DJANGO_SETTINGS_MODULE', 'wiki.settings' ) from django.core.management import execute_from_command_line execute_from_command_line(sys.argv) if __name__ == '__main__': main()The key line is:
os.environ.setdefault( 'DJANGO_SETTINGS_MODULE', 'wiki.settings' )This tells Django:
Use the settings stored in
wiki/settings.py.
What Commands Does
manage.pyRun?Some common examples:
Start the development server:
python manage.py runserverCreate migrations:
python manage.py makemigrationsApply migrations:
python manage.py migrateCreate an administrator account:
python manage.py createsuperuserOpen the Django shell:
python manage.py shellNotice that
manage.pydoes not store configuration settings. Its job is simply to execute commands.
What Is
settings.py?settings.pyis the project’s configuration file. It contains all the information Django needs in order to run properly.
Installed Applications
INSTALLED_APPS = [ 'encyclopedia', 'django.contrib.admin', 'django.contrib.auth', ... ]This tells Django which applications belong to the project.
Database Configuration
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }This tells Django which database system to use and where the database file is located.
Debug Mode
DEBUG = TrueThis enables detailed error messages during development.
Template Configuration
TEMPLATES = [...]This tells Django where to look for HTML templates.
Static Files
STATIC_URL = '/static/'This tells Django how CSS, JavaScript, and image files should be served.
How Do They Work Together?
Suppose we run:
python manage.py runserverThe sequence is:
manage.py ↓ Loads wiki.settings ↓ Reads INSTALLED_APPS Reads DATABASES Reads TEMPLATES Reads STATIC_URL ↓ Starts Django ServerIn other words:
manage.pyreceives the command.- It tells Django which settings file to use.
- Django loads
settings.py. - Django reads all project configurations.
- The requested command is executed.
CS50 Wiki Project Example
In the CS50 Wiki project, when you run:
python manage.py runserverDjango loads:
INSTALLED_APPS = [ 'encyclopedia' ]and knows that the Encyclopedia application exists.
It then reads:
DATABASESto connect to the SQLite database.
Next, it reads:
ROOT_URLCONF = 'wiki.urls'to locate the URL routes.
Only after all of these settings are loaded can the server start successfully.
Common Beginner Mistake
Many beginners think that
manage.pycontains the project settings because it references:'wiki.settings'However,
manage.pyonly points Django to the settings file. The actual configuration is stored insidesettings.py.
Key Takeaways
manage.pyis used to run Django commands.settings.pystores project configuration.manage.pyloadssettings.pybefore executing commands.- Without
settings.py, Django would not know how the project is configured. - Without
manage.py, running Django commands would be much more difficult.
Final Summary
manage.py answers the question:
“What should Django do?”
settings.py answers the question:
“How should Django be configured?”
Understanding this relationship is one of the first major steps toward understanding how a Django application starts, loads its configuration, and serves web pages.
-
AuthorPosts
- You must be logged in to reply to this topic.
