Introduction to Web Development with Django

  • Many of today’s websites are actually rich applications that act like fully developed desktop applications. We’ll develop a web app called Code Journals. It will allow you to log the Python topics you’re interested in and to make journal entries as you learn about each topic.

Advantages of Progressive Web Applications (PWA):

  • Removes the requirement to visit an app store
  • Access immediately through a browser
  • Eliminates the need to develop the app for multiple devices
  • Presents a customized version of the app to the user when they visit no matter the screen size or device type

What is Django?

  • Django is a web framework and includes a set of tools designed to help you build interactive web apps using Python.

How to Install Django (Windows)?

  • Open the VS Code terminal and run:
1pip install Django==6.1

Alternative for Windows users: you can also use the Python Launcher for Windows (py). The launcher is a small program that the standard python.org installer puts on your computer. It doesn’t run code itself. Its job is to find the Python installations on your machine and hand your command off to the right one.

1py -3.14 -m pip install Django==6.1

How to Install Django (Mac)?:

  • Open the VS Code terminal and run the command below. Use pip3, not pip.
1pip3 install Django==6.1

How Do I Create a Project in Django?

  • Enter the following commands:
1django-admin startproject code_journal .
2ls
  • Terminal Output:
1Name
2----
3code_journal
4manage.py
  • The first command above tells Django to setup a new project, code_journal
    • The dot at the end of the command creates the new project with a directory structure easy to work with. If you forget the dot, delete the files and folders that were created and run the command again.
    • Then, we run the ls command or dir, that shows Django has created a new directory called code_journal. It also created a file called manage.py.
1ls code_journal
  • Terminal Output:
1Name
2----
3__init__.py
4asgi.py
5settings.py
6urls.py
7wsgi.py
  • The code_journal directory contains five files.

Create a Database:

  • Like most websites, Django stores information related to projects in a database.
  • To create a database for a project, issue the following command:
1python manage.py migrate
  • Terminal Output:
1Operations to perform:
2  Apply all migrations: admin, auth, contenttypes, sessions
3Running migrations:
4--snip--
5Applying sessions.0001_initial... OK

  • Issue the ls command again to see what files are in the project directory now.
1ls
  • Terminal Output:
1Name
2----
3code_journal
4db.sqlite3
5manage.py
  • Anytime we modify a database, we say we’re migrating the database.
  • Issuing the migrate command, as noted above, tells Django to make sure the database matches the current state of the project.
  • Running the ls command shows that Django created another file called db.sqlite3

To View and Run your Project:

  • Issue the runserver command in your VS Code terminal as follows:
1python manage.py runserver
  • Terminal Output:
1System check identified no issues (0 silenced).
2October 19, 2026 - 10:50:58
3Django version 6.1, using settings 'code_journal.settings'
4Starting development server at http://127.0.0.1:8000/
5Quit the server with CTRL-BREAK.
  • Django first checks to make sure the project is set up properly
  • Then it reports the version of Django in use and the name of the settings file
  • It then reports the URL where to project is being served
    • The localhost (127.0.0.1) refers to a server that only processes requests on your system