0% found this document useful (0 votes)
30 views3 pages

Tutorial Django Kelas o

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Tutorial Django Kelas o

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

TUTORIAL DJANGO

1. python -m venv env_ku kalau gabisa bisa pake : python3 atau py


2. .\env_ku\Scripts\activate kalau gabisa bisa pake ini : source env_ku/bin/activate
3. pip install Django==4.2
4. django-admin startproject project_pertama
5. cd .\project_pertama\
6. python manage.py runserver
7. Buka di web : http://127.0.0.1:8000/

TUTORIAL INSTALL TEMPLATE FINAL PROJECT

1. cd .\ecomm\
2. python -m venv env_ecom
3. .\env_ecom\Scripts\activate kalau gabisa bisa pake ini : source env_ecom/bin/activate
4. edit requirements.txt menjadi seperti ini:
asgiref==3.6.0
# backports.zoneinfo==0.2.1
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.1.0
crispy-bootstrap5==0.7
cryptography==40.0.1
defusedxml==0.7.1
Django==4.2
django-allauth
django-countries
django-crispy-forms
django-environ
django-paypal
idna==3.4
oauthlib==3.2.2
Pillow==9.5.0
psycopg2-binary==2.9.6
pycparser==2.21
PyJWT==2.6.0
python3-openid==3.2.0
pytz==2023.3
requests==2.28.2
requests-oauthlib==1.3.1
sqlparse==0.4.3
typing_extensions
urllib3==1.26.15
5. pip install -r requirements.txt

6. rename (.template.env) menjadi .env. pastikan memiliki isi ini :


DEBUG=True
SECRET_KEY=!h6xi!hq-s@b(bd*)(6nsg+*vxm-2^sts3&5b6l6k5&b+=#$jp
[email protected]
[email protected]
PAYPAL_SANDBOX_CLIENT_ID=ARAwgueqXoENbLgYlvV6kno9jxkuMpMVttQ0JmGTWjt
AEAYDhVKEP_Y36r6hHbTOJjjXgbqBa_-AuhdQ
PAYPAL_SANDBOX_SECRET_KEY=ELgFGzEEfePUEARB_yrIltVLd-7EpK7W79yB0zbpoo
Hh8otjiWJ2BLUioMnWegDk_v0swmdlZpJcgdxd
PAYPAL_LIVE_CLIENT_ID=xxxx
PAYPAL_LIVE_SECRET_KEY=xxxx
[email protected]
PAYPAL_TEST=True

7. Pada setting.py di bagian Middleware tambahkan :


“allauth.account.middleware.AccountMiddleware”
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'allauth.account.middleware.AccountMiddleware'
]

8. Pada setting.py di bagian Database :


SQL lite : 102 - 107 buka, 109 - 118 comment

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# 'NAME': 'anton_db',
# 'USER': 'postgres',
# 'PASSWORD': '',
# 'HOST': 'localhost',
# 'PORT': '5432',
# }
# }

9. python manage.py migrate


10. python manage.py runserver
11. masuk ke URL http://127.0.0.1:8000/ akan muncul tampilan website
12. untuk mengatur database http://127.0.0.1:8000/admin
13. matikan dulu server dengan cara ctrl+c di terminal
14. lalu buat superuser,
15. python manage.py createsuperuser
16. username : zulfa, email : [email protected] password: admin123!
17. jalankan kembali server python manage.py runserver
18. buka http://127.0.0.1:8000/admin lalu login dan lakukan setting add product
19. tambahin product : klik product item -> add product item

You might also like