Today I learn Django #2
Published: 2020-12-10 15:46:39

Today I create a Django project and an app inside it. If you haven't seen my [first note](https://dev.to/ferry_ill/today-i-learn-django-1-2hcl) please kindly do.   
<p>&nbsp;</p>   
Btw, I skip the Django installation method, but basically when I created something with python, firstly I create a virtual environment and then install the package that I need. This time Django package.

OK... Today, I created a project called **wisdompets** using<br/> `django-admin startproject wisdompets`.

<p>&nbsp;</p>
After executing that syntax, Django creates a new folder with wisdompets as the name. Inside the folder, there is a folder with the same name that contains file .py.
![wisdompets_folder_as_project_folder](https://dev-to-uploads.s3.amazonaws.com/i/z9adptejej0yhe7l0d3f.png)

The explanation

|File Name   |Role   |
|:-:|:-:|
|manage.py   |Runs command for the project   |
|\_\_init\_\_.py   |Tell python the folder contains python code   |
|wsgi.py & asgi.py   |Files needed to connect to the live server    |
|settings.py   |Configure the Django project   |
|urls.py   |Routes web requests based on URL   |

<p>&nbsp;</p>
For \_\_pychache\_\_ folder and db.sqlite3 all I know is the files are generated after I run Django for the first time using `python manage.py runserver` syntax in the terminal. 

<p>&nbsp;</p>
The picture shown below is what I get after running the `runserver` syntax.
![Django run successfully](https://dev-to-uploads.s3.amazonaws.com/i/esocohg9abzgz94x8vdp.png)

<p>&nbsp;</p>
Interesting... Like I said in my [first note](https://dev.to/ferry_ill/today-i-learn-django-1-2hcl) about Django. Django project can has a couple of apps. But what is that mean? I confused before what is the meaning of a couple of apps. Because what I know is the project = app (read: the project is the same as an app. But I wrong. Apparently, what is meant like this, a web can have a blog, forum, or wiki inside it. This is what they call an app(blog, forum, etc). After knowing this I go like "Aaaah, I see know~".

<p>&nbsp;</p>
To create an app with **adoptions** as a name, I need to run<br/>
`python manage.py startapp adoptions`.

Again, the syntax will automatically generate a new folder with the app name. Look the picture bellow.
![Django app's files](https://dev-to-uploads.s3.amazonaws.com/i/roe7m2ek8pxlpi8p4ulp.png)

|Folder and File's Name   |Role   |
|:-:|:-:|
|admin.py   |Define administrative interface for the app that will allow us to see and edit the data related to the application   |
|apps.py   |Control settings specific for app   |
|models.py   |Provide data layer used by Django to create  database schema and queries  |
|test.py   |Used to write unit test for app functionality    |
|views.py   |Defines the logic and control flow for handling requests and defines the HTTP responses that are returned   |
|migrations/   |Folder that contains files used by Django do migrate database   |

Seem to much right? Agreed. Right now when I write this note, I still don't know much what that many files exactly do. Only the explanation that I know. As I continue to adventure, I will gradually level up.

Cover image -> <a href="https://www.freepik.com/vectors/technology">Technology vector created by grmarc - www.freepik.com</a>