Django Intro

How To Build Your First App In Python Django Framework — DjangoSeries Episode # 00

J3
Jungletronics
10 min readJul 25, 2021

--

Hi, we will make our first app in Django using anaconda environment in Atom in ten steps.

And how about Django?

It is used by many sites, including Pinterest, Instagram, Bitbucket, Washington Times, Mozilla and more!

Fig 1. Python + Django! Similar to Ruby On Rails Framework (MVC). I have Borrowed this image from this post

A Django application is a collections and configurations that when combined together will make up the full web application (your complete website running Django).

Each application is created (9th step) to perform a particular functionality (Registration, Polling, Comments, etc.)

We will use Atom as editor.

Let’s prepare our system.

Download Atom

Open Atom and install Atom Django (optional):

Fig 2. Atom’s Plugin atom-django

Install autocomplete-python (optional):

Install “autocomplete-python” package in Atom. { Welcome Guide -> Install a Package -> Open Installer -> Install -> (Search) autocomplete-python -> Install }

Fig 3. Atom’s Plugin autocomplete-python

Install “platformio-ide-terminal” package in Atom. { Welcome Guide -> Install a Package -> Open Installer -> Install -> (Search) platformio-ide-terminal -> Install }

Fig 4. Installing Atom’s Plugin Platformio (for Terminal use)

Then, Open Platformio-Ide-Terminal Settings { Welcome Guide -> Install a Package -> Open Installer -> Packages -> platformio-ide-terminal -> settings }.

🔑 Change Shell Override to “C:\WINDOWS\system32\cmd.exe” . {platformio-ide-terminal -> settings -> Core -> Shell Override}

👉 Download Anaconda Individual Edition and install it.

Now what matters: How to use Conda environments to code Django:

00#Step —Let’s activate Conda environment at Atom Terminal;

In the bottom left of Atom interface, click the plus sign, let’s run the terminal:

Fig 5. Atom’s Terminal plus sign

On Atom terminal, we need to Go To C:\Users\profile\anaconda3\Scripts\ and Run activate.bat Script, like this:

This will activate our Conda environment (prefixed with base).

Do not forget to override PowerShell terminal in platformio as key above 👆

Now we are ready to go!

01#Step — Make a Django Project Directory on Win Explorer:

02#Step — On Terminal, searching for dev environments:

That will brings our environments (just the base, so far…):

03#Step — Go To Atom, open folder and point to your newly created directory:

Fig 6. Atom’s Folder view

04#Step — For Creating Django Conda Env, Type:

The following packages will be downloaded:

04#Step — See if everything is all right:

You will see:

05#Step — Activating your newly created Django environment:

This results:

06#Step — Starting our Django Project:

This will create a new first-project directory, like this:

Fig 7. Atom’s first_project folder’s files — see descriptions on table I below
Table I — Django Project Folders’ Files Descriptions

07#Step — Lets use manage.py now:

Change to first_project directory and type on terminal:

Here is the output:

08#Step — Go To http://127.0.0.1:8000/

Fig 8. Congratulations! There you have it in your browser: your first Django app!

Now let’s talk about Migrations and Django Application.

As you can see (output above) there is a warning about 18 unapplied migrations.

Migration allows you to move databases from one design to another, this is also reversible.

So you can migrate your database.

For now you can ignore this warning.

Let’s continue and create our first Hello World Django Application.

Inside your project folder you can have any number of application. Awesome, right?

Let’s get some terminology straight about Django:

Table II — Django Terminologies Descriptions

09#Step — Let’s create our simple first app with this script:

Ctrl+c to stop the server, and type:

Fig 9. Atom’s First_App & First_Project’s Files created by the Fantastic Django machinery!

As you can see it will create others directories inside first_project directory.

Let’s see what does this files mean:

Table III — Django Project Folders’ Files Descriptions
Table IV— Django Application Folders’ Files Descriptions

10#Step — Now let’s learn the process of creating a view and mapping it to a URL!

Go To your Atom and open the first_project settings.py file, and type:

This will registrate your app inside your first project.

Now open first_app views.py and type:

Each view must return a HttpResponse return.

Fig 8. Django MVT; Image From this post

Now map this view in the the fisrt project urls.py file:

Finally just call the server again:)

And Go To your browser and point it to:

And here is the page:

Fig 10. Your Hello World First Application Running Beautifully \o/

Now, we have django project and 1 app running beautifully!

That’s all for today!

See you soon at the next Django Episode o/

Related Posts

00#Episode — DjangoSerie — Django Intro — How To Build your First App in Python Django Framework — DjangoSeries (this one)

01#Episode — DjangoSerie — Django MTV In VS Code — How To Install Django Inside Virtual VS Code

02#Episode — DjangoSerie — Can You Solve This in Python? — Here is A Basic Python Question!

03#Episode — DjangoSerie — JUNGLE-DJANGO Webpage! This Is My New Django Netflix Clone Page!

04#Episode — DjangoSerie — A Django Blog In VS Code — Quick Start!Part_I

05#Episode — DjangoSerie — A Django Blog In VS Code — Database, Migrations & Queries — Part_II

06#Episode — DjangoSerie — A Django Blog In VS Code — Bootstrap, Tailwind CSS — Part_III

07#Episode — DjangoSerie — A Django Blog In VS Code — Forms & Validations — Part_IV

08#Episode — DjangoSerie — A Django Blog In VS Code — Login & Logout — Part_V

09#Episode — DjangoSerie — A Django Blog In VS Code — Upload Profile Picture — Part_VI

10#Episode — DjangoSerie — A Django Blog In VS Code — Update & Resize Picture — Part_VII

11#Episode — DjangoSerie — A Django Blog In VS Code — Class-Based-View & CRUD — Part_VIII

12#Episode — DjangoSerie — A Django Blog In VS Code — Posts Pagination & Quick DB Population — Part_IX

13#Episode — DjangoSerie — A Django Blog In VS Code — Self-Service Django Password Reset — Part_X

14#Episode — DjangoSerie — A Django Blog In VS Code — Heroku Deploy — How To Push Your Site To Productio — Part_XI

Sharing is caring.

by me

Credits & References

Python and Django Full Stack Web Developer Bootcamp! by Jose Portilla

Introduction to ASGI: Emergence of an Async Python Web Ecosystem by Florimond Manca

Fig 11. Image From this post by Mitesh Prajapati

Another good articles by Phillip Oldham

Our greatest glory is not in never falling, but in rising every time we fall.

Confucius

--

--

J3
Jungletronics

😎 Gilberto Oliveira Jr | 🖥️ Computer Engineer | 🐍 Python | 🧩 C | 💎 Rails | 🤖 AI & IoT | ✍️