Creating a project:
django-admin startproject ProjectName
django-admin startproject STM
Which files are what?
NOTE, currently all these files are related to project and not our app
1. Manage.py :
2. wsgi.py : Web server that django creats for us
3. urls.py : URL ROUTING SYSTEM FOR OUR WEB PORTAL which will consist the
list of paths
4. settings.py : Command center of our django app
Launching a Django App:
python manage.py runserver
this will take us to default landing page of our django app
Turning off the server
CTRL + C
So now we have created a project, but we are building our django app
Hence we have to create it
Creating our app
python manage.py startapp appName
python manage.py startapp SmartTrafficManager
Our app will be created with the appName with following files
1. admin.py - Admin panel
2. model.py - We build our database and Classbase Objects.
3. views.py - Functions and classes that triggers our url patterns
Now that our app is created we need to configure, i.e add our appname in installed
app of settings.py so that Django server will know that appName is connected with
our Project
ABOUT URL Paths:
Whenever we use some url path, like /object it triggers the function
associated with that urlpattern and return template or api or any response
NOTE: -> Always create functions in views.py and use the urls.py to
route to those functions.
Using Templates: Basically HTML pages
Create a folder names "templates" with exact same spelling, create a folder
with your appname and store the html pages in it