Create a project folder – Use Windows Explorer to make a folder with project name.
Create virtual env – python -m venv name_of_project_folder
Enter the project folder – cd name_of_project_folder name_of_project_folder/scritps/activate (name_of_project_folder) …
Install Django – pip install “django>=3.0,<4.0”
Test installation – name_of_project_folder> python python version information appears make sure to exit()
Django installation check name_of_project_folder> python -m django –version
Starting proejct – (name_of_project_folder)…name_of_project_folder> django-admin start project name_of_project_folder2 name_of_project_folder2 will be created
Create database – name_of_project_folder> pythno manage.py migrate
Development server – name_of_project_folder> python manage.py runserverhttp://127.0.0.1:8000/
https://www.sublimetext.com/ Then open the src folder from sublime.
Every main category on top menu is considered as “app”.
After adding “app”, each “app” has to be added to the setting.py.
All html files go to separate folder. Create folder named “template” on src folder.
Every html files starts the same way. Then link base.html to setting.py.
Base directory is ‘src’. Once web address is typed, then base.html will show.
However, in order to show contents in the base.html, we need to have back-end code that will show contents in the base.html. This is done in the views.py under ‘personal’.
Then add the home_screen_view to the urls.py.
Less repetitive actions with Django content blocks. {% block ***** %} Then reference the home.html into base.html.
Whenever there is “block content”, then the home.html content will show.
Then change views.py.
snippets are used to repetitive use of codes. Create ‘snippets’ folder then create snippet.html file. Then use {% include ‘address directory to the html file ‘ %} A way to place html contents in a html file.
Displaying variable with Django by using {{}}. Variable is declared in the views.py. Change the last code to ‘context’.
Then place {{variable name }} in html file.
Showing list of values by using loops.
** list_item is a commend Result will show first entry second entry third entry fourth entry
** Add the body_snippet.html content to {{valuex }} When snippet is used with for loop, result will show Snippets from body_snippet.html first entry Snippets from body_snippet.html second entry Snippets from body_snippet.html third entry Snippets from body_snippet.html fourth entry