› 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
- This topic is empty.
-
AuthorPosts
-
May 10, 2026 at 3:46 am #6553
When beginners start learning Django, two files appear immediately:
manage.py settings.pyBoth are extremely important.
But they serve completely different purposes.
A simple way to remember them is:
manage.py → executes commands settings.py → stores configuration
What is
manage.py?manage.pyis Django’s command-line utility file.It allows us to run Django commands from the terminal.
Example:
#!/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()Using this file, we run commands like:
python manage.py runserver python manage.py migrate python manage.py createsuperuser python manage.py shellSo
manage.pyis mainly responsible for:- launching Django commands
- starting the development server
- interacting with Django from the terminal
Think of it as the project’s command launcher.
What is
settings.py?settings.pyis the central configuration file of the Django project.Example:
DEBUG = True INSTALLED_APPS = [ 'django.contrib.admin', 'encyclopedia', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', } }This file controls:
- installed apps
- database configuration
- template settings
- static files
- security settings
- timezone
- debug mode
So
settings.pydefines how Django behaves.Think of it as the project’s control center.
Simple Analogy
Imagine Django is a car.
manage.py = car ignition + controls settings.py = car configuration/settingsmanage.pystarts actions.settings.pydetermines how the system is configured.
How They Work Together
Inside
manage.py, there is an important line:os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wiki.settings')This tells Django:
"Use settings from wiki/settings.py"So when we run:
python manage.py runserverthe process becomes:
Terminal Command ↓ manage.py ↓ Loads settings.py ↓ Starts Django using those settings
Key Difference
manage.pyResponsible for ACTIONS.
Examples:
python manage.py runserver python manage.py migrate python manage.py shellThese are commands that do something.
settings.pyResponsible for CONFIGURATION.
Examples:
DEBUG = True TIME_ZONE = 'UTC' STATIC_URL = '/static/'These settings define project behavior.
Another Important Difference
manage.py- usually small
- rarely edited
- mostly remains unchanged
settings.py- edited very frequently
- can become very large
- production projects often split it into multiple files
Example:
settings/ base.py development.py production.py
Beginner Mental Model
manage.py = Django command launcher settings.py = Django configuration centerOnce this distinction becomes clear, Django’s architecture starts making much more sense.
-
AuthorPosts
- You must be logged in to reply to this topic.
