Python Importance.
Machine Learning
Spotify
Dropbox
Youtube
How to start working with django
1 Install python latest version
2 install virtualenv we don’t really need it if we are working on single project as dependencies will
3 intall django int the terminal run commnad (pip install django)
4 after that start project by giving command in terminal django-admin startproject happytails
5 Open the project to work on it. cd happytails
6 start django development server python manage.py runserver
7 running server will give us a port address copy and paste it in the browser to check if it's
Which file will be used for what in happytails?
1 urls.py for all the urls routing(list of urls we will have in our happytails)
2 wsgi.py web server gatway interface (actual server)
3 setting.py Main file (command center for our happytails) in this file, we will find installed app
next step is to start an app
1 Let’s start it by using a new terminal as we don’t want to close our server.
1 views.py it includes the functions or classes that will be triggered when user clicks specifi
2 Let the main project know that we have created a new app and want to work with it
1 urls.py if we create (functions or classes) also we can say views i.e fig 1, then those functions will be trigger o
These functions will throw message on the browser page
http://127.0.0.1:8000/ Welcome to Happy Tails!
http://127.0.0.1:8000/about About Happy Tails
BUT instread of creating messy code in the same main files, we should create functions and urls in the apps, and the
oject as dependencies will be installed globally. Virtualenv will install dep. Only for the specific project to avoid potential conflicts
roject happytails
the browser to check if it's working or not
, we will find installed apps which are actuall seprated parts of our project, like for chat sessions, reviews, authentication, etc.
python manage.py startapp basehappy Make sure you are in the django project (happytails) or it won’t start
ed when user clicks specific url,
open the settings.py and then look for installed apps, then add new app there like (basehappy.apps.BasehappyConfig). For
e functions will be trigger once the url is clicked or opened
d urls in the apps, and then link them to the main urls
duration
oid potential conflicts
uthentication, etc.
happytails) or it won’t start the app
pps.BasehappyConfig). For further info look into project 31.39
fig 1
38.29
template starts at 40