Wednesday, October 15, 2025

Introduction to Python Django | startproject | django app |VSCode.

Share

This is an introduction to the Django Framework from installation to a Web Development Project. The initial steps I will introduce are from using the command line to adding packages and moving forward from there with each post. Each post will take over from where the last post ended, so follow in an order how the project builds up and items I introduce.

The majority of the items I will post here are for myself as I am using the website as a digital notebook for myself to add this stuff as a reference for me if I need to look it up again in the future when developing a web page, website, full stack application, APIs using Django, or anything related to Mobil as well. I will add pictures, videos, screenshots, etc from others and myself of course or youtube links that help me understand something that references what I am coding.

Hopefully if you like you can create links to any post if needed. This is both and digital notebook as I mentioned and a learning website for myself for understanding and clarity.

So I will start with adding all my packages and go from there. Thanks folks.

Command Line:

First, open up your command line tool on your macbook pro and type the following:

  1. ls (it will list your current directory [LS is what I typed])
  2. cd Desktop (change your location to your Desktop folder)
  3. mkdir test_folder (make a directory for a new folder)
  4. cd test_folder (change your location to your test_folder)
  5. python3 –version (now check the version of python you have on your macbook pro, if you do not have it download and add NOW)
  6. python3 -m venv .venv (NOW, create your virtual environment your will be using for your application)
  7. source .venv/bin/activate (NOW, type this to activate your virtual environment) [you should see the following in the command line
  8. python3 -m pip install django (Now, install the django framework). You should be ready to go.

Viewing VSCode Folder Structure:

This is what you should see once your open your VSCode if that is the IDE you are using.

Working Inside the VSCode Environment.

  • Within the VSCode environment open up the terminal up top on tool bar “TERMINAL” it should show up in the bottom there. You may have to start your venv again so type the following: ‘source .venv/bin/activate”.
  • Once you type that above you can now create your first django project. Type the following: “django-admin startproject test_django .” Explained: ‘django-admin startproject” [this is how you start the code to create your project] Next, ‘test_django‘ is the name of the folder/project. Lastly, the period your see at the end of the line is so you DO NOT CREATE AN EXTRA FOLDER WITHIN EACH OTHER. IT CREATE JUST ONE FOLDER YOU WILL WORK IT. TRY IT WITHOUT THE PERIOD AND SEE.
  • Lastly, type the following: python manage.py runserver. YOU SHOULD SEE THIS BELOW.

Main Project Code For Your Application in VSCode – Django Startproject:

The code will show this within VSCode –

I will just explain the following parts of the code output after you created it within VSCode.

The (settings.py) – is the settings and configurations for your project, it has all the default settings but this is where your connect your apps, add Media connection, static file connection, etc. Its almost as if this is the heart of the project and makes it work.

The (urls.py) – file is the main connection urls for your entire project. If you make a URLs.py file within any ‘app’ it will connect to the urls.py file within this main project folder. These are all mapped to the VIEWS.py file which in turn hit up the db.

The rest of the file I would just pull up a link and read what they are and what they do. Here is a link for them CREATING A PROJECT

Final Step – Creating Django Framework Project – Django App within StartProject:

Within the ‘startproject’ you created above you will now need to create a ‘Django App’. This is the application you will be working on throughout your project or application you want to create. The application or project can be a Blog Website, ToDo List Website, etc. HERE IS THE LOOK OF THE DJANGO APP CREATED:

Concentrate only on the files within the ‘blog’ folder, as I mentioned before the ‘django1’ folder is the main project, your application is the ‘blog’ folder. An overview oof the files is listed below, which is the ARCHITECTURE OF DJANGO. What is missing within this folder is the following; ‘URLs.py’ file (you add it here) and a FOLDER CALLED – TEMPLATES (where all your html, css, js, whatever you want in it but I would advise to ORGANIZATION your folders and files out). Follow explanation below for the architecture of django.

Django Architecture Explained in a Diagram:

Before getting any further into Django lets look at the architecture of the framework you will use. This is a very simple diagram with all credit due to edureka slide deck.

Architecture Explained (Model, View, Template, Urls:

The following three components explains what they do within the django framework. The three components are Model, View, Template, URLs.

Model – is the Logical data within the framework, it handles the data for the framework. It is the go inbetween for the DATABASE and the VIEW. What you create within your Model is translated into your database by creating the columns and rows.

Template – is the HTML template you created to display your project.

View – is the communicating layer of the Django Framework. It basically talks to the Model which in turn returns or does whatever you created it to do within your project. It pulls from database and it is sent to the Template for viewing purposes.

URLs – is the link that sends you to the appropriate VIEW

Django Architecture and How It Works:

How Django Framework Works, steps to execution.Someone request a page from your Django framework website. Its an HTTP Request to the URLs. Django Framework finds the matching URL requested.Django Framework now pulls up the VIEW it requested by the URLs. The VIEW now uses the MODEL it is associated with to pull DATA from. The MODEL queries the database now. The data is grabbed for viewing. The VIEW renders an HTML Template for VIEWING and returns your HTTP Response.

Read more

Local News