First of all: SET UP DJANGO:
Open directory
Open Terminal
pip install django
***********************RESTART TERMINAL**********
CREATE A DJANGO PROJECT:
1: django-admin startproject project_name
--->
OUTPUT:generation of a new directory that contains a banch of files that are
generated by django
****************************************
_init_.py:a special file that tells python to treat this file like a python
package.
[Link]/[Link]: configuration files that allows django to communicate with the web
server( we won't deal with these files)
[Link]: install django application, plugins, middleware, & modify database
engines.
[Link]: configuration of URL routes to direct django apps
[Link]: special file that acts like a command line tool, allows us to run
special commands like, make database migrations, run our python server, creating
users for our admin panel ...
***************************************
If we want to have any executable code or be able to see the website appearing we
need to create something known as a Django app
NB: A DJANGO APP IS MEANT TO BE A STANDALONE APPLICATION THAT WE CAN PLUG AND PLAY
(move it from a project to another)
// DJANGO APPS contains :
* database models
* views/routes
* templates
* other stuff ..
****************************************
CREATE A DJANGO APP:
2.1: cd to the django project directory
2.2: python [Link] startapp app_name ( app created)
TO LINK THIS APP TO THE DJANGO PROJECT WE NEED TO ADD THE APP NAME TO THE
[Link] OF THE PROJECT
2.3: create a [Link] file : where we gonna create diffent URL routes and connect
them to our
TO CREATE A VIEW WE TYPE :
from [Link] import render, HttpResponse
def home(request):
return HttpResponse("Hello World")
to connect this view with a url :
@[Link] :
from [Link] import path
from . import views
urlpatterns =[
path("", [Link], name="home")
]
now after configuring the url OF our app, we need to configure the url TO our app