Django Create Project

https://python.plainenglish.io/setting-up-a-basic-django-project-with-pipenv-7c58fa2ec631 https://youtu.be/F_xWv0Q_dLE https://www.youtube.com/watch?v=tRGV_DoWyrI ' https://www.youtube.com/watch?v=xrovglBdBqk (Template) https://www.youtube.com/watch?v=sv6kMpCcVIs (Static file)

Step-1: Create Folder (BookingEngine) and go into this folder

Step-2: Check Python and Pip is installed or not (python --version, pip --version)

Step-3: Check Django is installed or not (django-admin --version)-> You will get django is not installed.

========= First create pipenv virtual Envirment ==========

Step-4: pip install pipenv (To install the pipenv)

step-5: Check pipenv --version

step-6: Activate pipenv by using commond 'pipenv shell' (It will create file Pipfile)

step-7: To remove the pipenv use commond 'pipenv --rm'

========= Install django and create project ==========

step-8: Install django by using 'pipenv install django' (It will create file Piplock file)

step-9: django-admin startproject BookingEngine . (. into the last is must to create manage.py in root, orhetwise it will create folder within folder)

step-10: python manage.py runserver

step-11: pip freeze > requirements.txt (To generate the requirements.txt)

step-12: Create app : python manage.py startapp users

========= Create Template Folder ==========

step-13: Create Templates folder under the root project BookingEngine with the sub directory if there.

step-14: Go into setting page and create a variable

TEMPLATES_DIR =os.path.join(BASE_DIR,'templates')

After that set this variable into Template directory:

TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATES_DIR], }]

========= Create Static Folder ==========

step-15: Create static folder under the root project BookingEngine

step-16: Go into setting page and create a variable for static folder

STATIC_URL = '/static/'

STATIC_DIR =os.path.join(BASE_DIR,'static')

STATICFILES_DIRS =[STATIC_DIR]

========= Load static file into template==========


{% load static %}

link href="{% static 'css/style.css' %}" OR link href="{% get_static_prefix %}css/style.css"

Python Documents

https://www.edureka.co/blog/interview-questions/python-interview-questions/#Whattypeoflanguageispython?
1What kind of model in Python?
MVT(Model View Template)
1check python install
python --version
1What is pip?
pip (package manager, We can install any module by pip commond: pip install)
-: pip list
-: pip uninstall name_of_module
1Check and install django
pip (package manager, We can install any module by pip commond: pip install)
-: pip install django
-: python -m django --version (3.1)
1How to create project in Python
-: python-admin startproject MyBlog
1Run server
-: python manage.py runserver
1close server before create app.
-: press ctrl+c
1Create app
-:python manage.py startapp login
1Create Envorment PIPENV
https://www.codingforentrepreneurs.com/projects/setup-python-and-django-windows/create-django-project/?play=true
1- First i have created a folder for pipenv envorment project "MyProject/MyBlog"
2- commond: pip install pipenv
3- commond: clear
4- commond: pipenv install requests (this commond will create a virtual envorment this project and crated pipfile in this folder)
5- commond:
-pipenv shell (activate pipenv)
-pip freeze (this will show what we have installed in this envorment)
6 - python -m pip freeze (Show what is in global)
7- python (it will show which python version is in this envorment)
- import sys (this will import all feature)
- print(sys.executable)
1pipenv install django
1- pipenv install django==3.1.1
-pip freeze(check install module)
-pip install requests (collect packages)
-pip freeze > requirements.txt (another way to track what you have installed)
-pipenv install -r requirements.txt (Requirment file provided, import into pipfile)
1Static Directroy
STATICFILES_DIRS =[
os.path.join(BASE_DIR,'static')
]
STATIC_ROOT =os.path.join(BASE_DIR,'assets')
After that i have run commond: python manage.py collectstatic (This commond will collect all the static file into djang asstes)
X