29
loading...
This website collects cookies to deliver better user experience
Blog
. TO do that, we'll create a folder called Blog
, install and set up the virtual environment as discussed and explained in the previous part. django-admin startproject Blog .
venv
( using -I venv
option on tree command) as it is out of the scope of this series. The venv
folder contains modules and scripts which are installed in the virtual environment. manage.py
file which is to execute several commands at a project level. We do not have to edit any of the contents of this file (never). It is the file that allows us to run the server, apply migrations, create an Admin account, create apps, and do a lot of crucial things with the help of python. __init__.py
file. The purpose of the __init__.py
file is to tell the Python environment that the current folder is a Python package. settings.py
file, we can do some of the following operations : applications
that might be pre-installed or user-defined. Blogging Platform
might have an application for posts
, users
, api
, homepage
, etc. So the project Blogging Platform
might have separated the components like its API, Homepage, Post, Users, and so on to keep the development independent and well organized. posts
app in another project or in a particular app of the same project making it easier and faster to create the project. URL
routes of the project. We'll discuss URLs and Views in their own part in the series. This file basically has a list of URLs that should be paired with a view
or any other function. In the project folder, the URL patterns mostly link a baseurl to the URL file of the particular application. Don't worry if you can't get some of the terms, you'll clearly understand when we see them in the future parts of this series. startapp
option with the python manage.py
command followed by the name of the app like:python manage.py startapp name
name
can be any app name you'd like to give. models.py
, views.py
, test.py
. There are other files that we will create manually like the urls.py
, serializers.py
, etc. INSTALLED_APPS
list in the settings.py
file. Something like this: Fields
, Relationship
, Meta-data
, methods
, etc. These are defined with the help of python along with the Django Models. In most cases, a model is like a single table
in an actual database. SQL
queries to create the database. migration
or actual query that runs to create the table or the database structure. There might be multiple steps or iteration of the database, this folder stores those pieces of information. .git
folder but for keeping track of the migrations or changes to the database. Admin section
without touching any frontend part. It provides a built-in CRUD
(Create Read Update Delete) functionality to the model. This is really good for testing up the model manually before putting effort into the frontend part. Admin section
in this series. urls.py
file. There are a couple of approaches when it comes to writing the format of the functions like class-based views
, function-based views
, and others depending on the type of operation is been done. V
(View) in the MVT
architecture in Django Framework. This is the place where we write the logic from the server-side to let's say render HTML pages(templates), query to the database with CRUD operations, return an HTTP response, etc. urls.py
is specific to the app and it might be prefixed with the URL route mentioned in the project folder's urls.py
file. templates
, static
, media
, etc. There are also python package-specific folders for which you may need to create folders. css
, javascript
, and images
(images or media files that are used in the templates). This is a good way to improve the performance as in the production the webserver collects all the static files and stores them in a single place for responding to the requests. The template folder if present in the root folder, has a sub-folder as the application names and inside the app-name
, we put in all the .html
or other template files. template
folder, the location can be modified or set as a configuration from the settings.py file. Usually, the static files(.css
, js
, etc) are stored in the root folder with app names as subfolders.