From 13a3737fbc447585bf60cf7a1a5f6250d12c30a4 Mon Sep 17 00:00:00 2001 From: sina lalehbakhsh Date: Sun, 7 Jan 2024 13:04:49 -0500 Subject: [PATCH] =?UTF-8?q?=20=F0=9F=92=A0=20121-Django/Practice=5F01-30/P?= =?UTF-8?q?ractice-13=20Online=20Shop=20Image-10=20create=20new=20app=20fo?= =?UTF-8?q?r=20products=201-=20write=20in=20a=20directory=20Terminal=202-?= =?UTF-8?q?=20Create=20private/public=20repository=20in=20your=20account?= =?UTF-8?q?=20github=203-=20in=20Terminal=20->=20echo=20'#=20OnlineShope'?= =?UTF-8?q?=20>>=20README.md=204-=20in=20Terminal=20->=20git=20init=205-?= =?UTF-8?q?=20in=20Terminal=20->=20git=20add=20README.md=206-=20=20in=20Te?= =?UTF-8?q?rminal=20->=20git=20commit=20-m=20'first=20commit'=207-=20=20in?= =?UTF-8?q?=20Terminal=20->=20git=20branch=20-M=20main=208-=20=20in=20Term?= =?UTF-8?q?inal=20->=20git=20remote=20add=20origin=20git@github.com:?= =?UTF-8?q?=E2=9B=94YOUR=5FUSER=5FNAME=E2=9B=94/OnlineShope.git=209-=20=20?= =?UTF-8?q?in=20Terminal=20->=20git=20push=20-u=20origin=20main=2010-=20Ch?= =?UTF-8?q?eck=20your=20repository=20link,=20make=20sure=20that=20will=20c?= =?UTF-8?q?hanged=2011-=20paste=20everything=20from=20directory=20you=20cl?= =?UTF-8?q?oned=20in=20step=201=20from=20this=20link=20https://github.com/?= =?UTF-8?q?hadiMh/Django=5FDocker=5Fwith=5FPostgreSql=2012-=20paste=20this?= =?UTF-8?q?=20file=20from=20this=20link=20in=20U.sh=2013-=20change=20permi?= =?UTF-8?q?ssion=20U.sh=20by=20this=20command=20in=20Terminal=2014-=20Chec?= =?UTF-8?q?k=20permission=20file=20by=20this=20command=20in=20Terminal=201?= =?UTF-8?q?5-=20run=20this=20for=20first=20time=20use=20docker-compose=201?= =?UTF-8?q?6-=20write=20in=20Terminal=20->=20docker-compose=20up=20--build?= =?UTF-8?q?=2017-=20Run=20strong=20VPN=20and=20write=20again=20in=20Termin?= =?UTF-8?q?al=2018-=20write=20Ctrl=20+=20C=20key=20and=20shut=20it=20down?= =?UTF-8?q?=2019-=20Run=20again=20(strong=20VPN=20activated)=2020-=20Check?= =?UTF-8?q?=20in=20browser=20should=20see=20default=20django=20page=20?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=20BEFORE=20migrate=20=E2=9B=94?= =?UTF-8?q?=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94?= =?UTF-8?q?=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94?= =?UTF-8?q?=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94?= =?UTF-8?q?=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94?= =?UTF-8?q?=E2=9B=94=E2=9B=94=E2=9B=94=E2=9B=94=20If=20for=20any=20reason?= =?UTF-8?q?=20you=20have=20to=20rebuild=20and=20delete=20containers=20web?= =?UTF-8?q?=20+=20databas=20You=20need=20run=20again=20these=20command=20b?= =?UTF-8?q?efore=20to=20continue=20docker-compose=20up=20--build=20docker-?= =?UTF-8?q?compose=20exec=20web=20python=20manage.py=20makemigrations=20do?= =?UTF-8?q?cker-compose=20exec=20web=20python=20manage.py=20migrate=20dock?= =?UTF-8?q?er-compose=20exec=20web=20python=20manage.py=20createsuperuser?= =?UTF-8?q?=2021-=20in=20Terminal=20->=20docker-compose=20exec=20web=20pyt?= =?UTF-8?q?hon=20manage.py=20startapp=20accounts=2022-=20add=20accounts=20?= =?UTF-8?q?in=20config/settings.py=20>=20INSTALLED=5FAPPS=20list=2023-firs?= =?UTF-8?q?t=20docker=20rm=20containers=20and=20second=20rmi=20image=2024-?= =?UTF-8?q?=20create=20fake=20venv,=20write=20in=20Terminal=2025-=20Create?= =?UTF-8?q?=20.gitignore=20file=20and=20add=20this=20into=20it=2026-=20imp?= =?UTF-8?q?ort=20this=20into=20accounts/models.py=2027-=20create=20new=20c?= =?UTF-8?q?lass=20in=20accounts/models.py=2028-=20Create=20forms.py=20in?= =?UTF-8?q?=20accounts=20directory=2029-=20import=20this=20in=20accounts/f?= =?UTF-8?q?orms.py=2030-=20Create=20new=20class=20in=20accounts/forms.py?= =?UTF-8?q?=2031-=20add=20this=20in=20config/settings.py=2032-=20Create=20?= =?UTF-8?q?new=20class=20in=20accounts/forms.py=2033-=20import=20this=20in?= =?UTF-8?q?to=20accounts/admin.py=2034-=20create=20new=20class=20in=20acco?= =?UTF-8?q?unts/admin.py=2035-=20in=20Terminal=20->=20docker-compose=20exe?= =?UTF-8?q?c=20web=20python=20manage.py=20makemigrations=2036-=20in=20Term?= =?UTF-8?q?inal=20->=20docker-compose=20exec=20web=20python=20manage.py=20?= =?UTF-8?q?migrate=2037-=20in=20Terminal=20->=20docker-compose=20exec=20we?= =?UTF-8?q?b=20python=20manage.py=20createsuperuser=2038-=20in=20Terminal?= =?UTF-8?q?=20->=20docker-compose=20up=20--build=20=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=20For=20All=20Projects=20=F0=9F=92=A0?= =?UTF-8?q?=F0=9F=92=A0=F0=9F=92=A0=20=20=20=20=201-=20in=20Terminal=20=20?= =?UTF-8?q?=20=20=20docker-compose=20up=20--build=20=20=20=20=20=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=20=20=20=20=202-=20in=20Terminal=20=20=20=20=20Ctrl?= =?UTF-8?q?=20+=20C=20key=20=20=20=20=20=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20=20=20=20=20?= =?UTF-8?q?3-=20in=20Terminal=20=20=20=20=20docker=20start=202=5Fdjango=5F?= =?UTF-8?q?haji=5Fweb=5F1=202=5Fdjango=5Fhaji=5Fdb=5F1=20=20=20=20=20OR=20?= =?UTF-8?q?=20=20=20=20docker=20start=20web=5FName=20dataBase=5FName=20=20?= =?UTF-8?q?=20=20=20=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=20=20=20=20=204-=20in=20Terminal=20?= =?UTF-8?q?=20=20=20=20docker-compose=20exec=20web=20python=20manage.py=20?= =?UTF-8?q?makemigrations=20=20=20=20=20=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20=20=20=20=20?= =?UTF-8?q?5-=20in=20Terminal=20=20=20=20=20docker-compose=20exec=20web=20?= =?UTF-8?q?python=20manage.py=20migrate=20=20=20=20=20=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=20=20=20=20=206-=20in=20Terminal=20=20=20=20=20docker-compose?= =?UTF-8?q?=20up=20--build=20=20=20=20=20=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20=20=20=20=20?= =?UTF-8?q?7-=20in=20another=20Terminal=20=20=20=20=20docker-compose=20exe?= =?UTF-8?q?c=20web=20python=20manage.py=20createsuperuser=20=20=20=20=20?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D?= =?UTF-8?q?=3D=3D=3D=3D=3D=3D=20=20=20=20=208-=20in=20browser=20=20=20=20?= =?UTF-8?q?=20http://127.0.0.1:8000/admin/login/=3Fnext=3D/admin/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Output, it must be implemented correctly 39- in Terminal -> docker-compose exec web python manage.py startapp pages 40- add pages in config/settings.py > INSTALLED_APPS list -> 'pages', 41- import this into pages/views.py -> from django.views.generic import TemplateView 42- create new two classes into pages/views.py 43- Create tempaltes/home.html in current directory of project -> tempaltes/home.html 44- write in tempaltes/home.html -> Home Page is Here Dear YOUR_NAME :) 45- write this in config/settings.py TEMPLATES list -> 'DIRS': [str(BASE_DIR.joinpath('templates'))], 46- Rebuild Server -> docker-compose up --build 47- Create tempaltes/pages/aboutus.html in pages directory -> templates/pages/aboutus.html 48- Write in tempaltes/pages/aboutus.html -> About Us YOU from Earth 49- import this in config/urls.py -> from django.urls import include 50- write into config/urls.py > urlpatterns list -> path('', include('pages.urls')), 51- Create urls.py in pages directory -> urls.py 52- import in pages/urls.py 53- Create urlpatterns list in pages/urls.py 54- Rebuild server in Terminal -> docker-compose up --build 55- Remove previous images maybe are like this IDs 56- Check browser 57- write this in config/settings.py in urlpatterns list 58- Create urls.py in accounts directory 59- import into accounts/urls.py 60- Create urlpatterns list in accounts/urls.py 61- import into accounts/views.py 62- Create new class into accounts/views.py 63- Create registration/login.html AND registration/signup.html in templates current directory project 64- write these in templates/registration/signup.html 65- write these in templates/registration/login.html 66- Rebuild Server -> docker-compose up 67- Check browser -> http://127.0.0.1:8000/admin/ 68- Check this link -> http://127.0.0.1:8000/accounts/login/ 69- Check this link -> http://127.0.0.1:8000/accounts/logout/ 70- Check this link -> http://127.0.0.1:8000/accounts/signup/ 71- write this in config/settings.py 72- make sure server is true running like this 73- Check these links should be redirected after login/logout 🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑🥑 You Can write TEST for everything in this step in test.py file Apps 74- in another Terminal (Server should be acticeted now) -> docker-compose exec web pip install django-crispy-forms 75- Check requirements.txt must be like this 76- in another Terminal (Server should be acticeted now) -> docker-compose exec web pip freeze > requirements.txt 77- Check requirements.txt must be Changed like this 78- write this into config/settings.py in INSTALLED_APPS > after Djangop default Apps 79- for convinience way to after this step, write this in Terminal -> pipenv install 80- for running any command for (docker-compose exec web ...) in terminal 🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲🧲 From now on, execute Docker-compose commands inside this terminal, when the pipenv environment is not active. 81- Create _base.html in templates directory -> _base.html 82- write html:5 in file _base.html and Press Enter(return) 83- search in browser 'bootstrap' 84- Copy 'Bootstrap CSS' from this link -> https://getbootstrap.com/docs/5.3/getting-started/introduction/ 85- Paste that in head tag of _base.html 86- Copy