From f909af0792fb47f91abc860566b579ab3c62e672 Mon Sep 17 00:00:00 2001 From: sina lalehbakhsh Date: Mon, 29 Jan 2024 12:00:42 -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-15=20=20=20i18n=201-=20write?= =?UTF-8?q?=20in=20a=20directory=20Terminal=202-=20Create=20private/public?= =?UTF-8?q?=20repository=20in=20your=20account=20github=203-=20in=20Termin?= =?UTF-8?q?al=20->=20echo=20'#=20OnlineShope'=20>>=20README.md=204-=20in?= =?UTF-8?q?=20Terminal=20->=20git=20init=205-=20in=20Terminal=20->=20git?= =?UTF-8?q?=20add=20README.md=206-=20=20in=20Terminal=20->=20git=20commit?= =?UTF-8?q?=20-m=20'first=20commit'=207-=20=20in=20Terminal=20->=20git=20b?= =?UTF-8?q?ranch=20-M=20main=208-=20=20in=20Terminal=20->=20git=20remote?= =?UTF-8?q?=20add=20origin=20git@github.com:=E2=9B=94YOUR=5FUSER=5FNAME?= =?UTF-8?q?=E2=9B=94/OnlineShope.git=209-=20=20in=20Terminal=20->=20git=20?= =?UTF-8?q?push=20-u=20origin=20main=2010-=20Check=20your=20repository=20l?= =?UTF-8?q?ink,=20make=20sure=20that=20will=20changed=2011-=20paste=20ever?= =?UTF-8?q?ything=20from=20directory=20you=20cloned=20in=20step=201=20from?= =?UTF-8?q?=20this=20link=20https://github.com/hadiMh/Django=5FDocker=5Fwi?= =?UTF-8?q?th=5FPostgreSql=2012-=20paste=20this=20file=20from=20this=20lin?= =?UTF-8?q?k=20in=20U.sh=2013-=20change=20permission=20U.sh=20by=20this=20?= =?UTF-8?q?command=20in=20Terminal=2014-=20Check=20permission=20file=20by?= =?UTF-8?q?=20this=20command=20in=20Terminal=2015-=20run=20this=20for=20fi?= =?UTF-8?q?rst=20time=20use=20docker-compose=2016-=20write=20in=20Terminal?= =?UTF-8?q?=20->=20docker-compose=20up=20--build=2017-=20Run=20strong=20VP?= =?UTF-8?q?N=20and=20write=20again=20in=20Terminal=2018-=20write=20Ctrl=20?= =?UTF-8?q?+=20C=20key=20and=20shut=20it=20down=2019-=20Run=20again=20(str?= =?UTF-8?q?ong=20VPN=20activated)=2020-=20Check=20in=20browser=20should=20?= =?UTF-8?q?see=20default=20django=20page=20=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=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=20?= =?UTF-8?q?BEFORE=20migrate=20=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=E2=9B=94=E2=9B=94=E2=9B=94?= =?UTF-8?q?=E2=9B=94=20If=20for=20any=20reason=20you=20have=20to=20rebuild?= =?UTF-8?q?=20and=20delete=20containers=20web=20+=20databas=20You=20need?= =?UTF-8?q?=20run=20again=20these=20command=20before=20to=20continue=20doc?= =?UTF-8?q?ker-compose=20up=20--build=20docker-compose=20exec=20web=20pyth?= =?UTF-8?q?on=20manage.py=20makemigrations=20docker-compose=20exec=20web?= =?UTF-8?q?=20python=20manage.py=20migrate=20docker-compose=20exec=20web?= =?UTF-8?q?=20python=20manage.py=20createsuperuser=2021-=20in=20Terminal?= =?UTF-8?q?=20->=20docker-compose=20exec=20web=20python=20manage.py=20star?= =?UTF-8?q?tapp=20accounts=2022-=20add=20accounts=20in=20config/settings.p?= =?UTF-8?q?y=20>=20INSTALLED=5FAPPS=20list=2023-first=20docker=20rm=20cont?= =?UTF-8?q?ainers=20and=20second=20rmi=20image=2024-=20create=20fake=20ven?= =?UTF-8?q?v,=20write=20in=20Terminal=2025-=20Create=20.gitignore=20file?= =?UTF-8?q?=20and=20add=20this=20into=20it=2026-=20import=20this=20into=20?= =?UTF-8?q?accounts/models.py=2027-=20create=20new=20class=20in=20accounts?= =?UTF-8?q?/models.py=2028-=20Create=20forms.py=20in=20accounts=20director?= =?UTF-8?q?y=2029-=20import=20this=20in=20accounts/forms.py=2030-=20Create?= =?UTF-8?q?=20new=20class=20in=20accounts/forms.py=2031-=20add=20this=20in?= =?UTF-8?q?=20config/settings.py=2032-=20Create=20new=20class=20in=20accou?= =?UTF-8?q?nts/forms.py=2033-=20import=20this=20into=20accounts/admin.py?= =?UTF-8?q?=2034-=20create=20new=20class=20in=20accounts/admin.py=2035-=20?= =?UTF-8?q?in=20Terminal=20->=20docker-compose=20exec=20web=20python=20man?= =?UTF-8?q?age.py=20makemigrations=2036-=20in=20Terminal=20->=20docker-com?= =?UTF-8?q?pose=20exec=20web=20python=20manage.py=20migrate=2037-=20in=20T?= =?UTF-8?q?erminal=20->=20docker-compose=20exec=20web=20python=20manage.py?= =?UTF-8?q?=20createsuperuser=2038-=20in=20Terminal=20->=20docker-compose?= =?UTF-8?q?=20up=20--build=20=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=20For=20?= =?UTF-8?q?All=20Projects=20=F0=9F=92=A0=F0=9F=92=A0=F0=9F=92=A0=20=20=20?= =?UTF-8?q?=20=201-=20in=20Terminal=20=20=20=20=20docker-compose=20up=20--?= =?UTF-8?q?build=20=20=20=20=20=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=3D=3D=3D=3D=20=20=20=20=202-=20in?= =?UTF-8?q?=20Terminal=20=20=20=20=20Ctrl=20+=20C=20key=20=20=20=20=20=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=3D=3D=20=20=20=20=203-=20in=20Terminal=20=20=20=20=20?= =?UTF-8?q?docker=20start=202=5Fdjango=5Fhaji=5Fweb=5F1=202=5Fdjango=5Fhaj?= =?UTF-8?q?i=5Fdb=5F1=20=20=20=20=20OR=20=20=20=20=20docker=20start=20web?= =?UTF-8?q?=5FName=20dataBase=5FName=20=20=20=20=20=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=3D=3D=3D=3D=20?= =?UTF-8?q?=20=20=20=204-=20in=20Terminal=20=20=20=20=20docker-compose=20e?= =?UTF-8?q?xec=20web=20python=20manage.py=20makemigrations=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=205-=20in=20Terminal=20=20=20=20?= =?UTF-8?q?=20docker-compose=20exec=20web=20python=20manage.py=20migrate?= =?UTF-8?q?=20=20=20=20=20=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=3D=3D=20=20=20=20=206-=20in=20Termi?= =?UTF-8?q?nal=20=20=20=20=20docker-compose=20up=20--build=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=207-=20in=20another=20Terminal?= =?UTF-8?q?=20=20=20=20=20docker-compose=20exec=20web=20python=20manage.py?= =?UTF-8?q?=20createsuperuser=20=20=20=20=20=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=3D=20=20=20=20?= =?UTF-8?q?=208-=20in=20browser=20=20=20=20=20http://127.0.0.1:8000/admin/?= =?UTF-8?q?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