github sourcecodes: https://github.com/dev-rathankumar/greatkart-course udemy: https://www.udemy.com/course/django-ecommerce-project-based-course-python-django-web-development/learn/lecture/25940412#questions/14475060
new file: .gitignore
new file: README.md
λ python -m venv venv3932
λ venv3932\scripts\activate
(venv3932) λ python -m pip install django
(venv3932) λ python.exe -m pip install --upgrade pip
(venv3932) λ django-admin startproject config .
modified: README.md
modified: apps/main/apps.py
modified: config/settings.py
new file: db.sqlite3
modified: README.md
new file: apps/main/urls.py
modified: apps/main/views.py
modified: config/settings.py
modified: config/urls.py
new file: templates/main/index.html
modified: README.md
...
new file: config/static/js/jquery-2.0.0.min.js
new file: config/static/js/script.js
modified: templates/main/index.html
modified: README.md
modified: config/settings.py
(venv3932) λ python manage.py collectstatic
201 static files copied to 'E:\workspace\django\ECOMMERCE\rathan_advance_ecommerce\src\static'.
modified: README.md
new file: static/admin/fonts/Roboto-Bold-webfont.woff
...
new file: static/js/jquery-2.0.0.min.js
new file: static/js/script.js
modified: README.md
modified: templates/main/index.html
modified: README.md
new file: templates/main/inc/banner.html
new file: templates/main/inc/content.html
modified: templates/main/index.html
new file: templates/shared/footer.html
new file: templates/shared/head.html
new file: templates/shared/header-main.html
new file: templates/shared/header-top.html
modified: README.md
new file: templates/base.html
modified: templates/main/index.html
modified: README.md
new file: config/.env
(venv3932) λ pip install django-environ
modified: README.md
modified: config/.env
hp=# create database django_rathan_greatkart;
CREATE DATABASE
hp=#
(venv3932) λ python -m pip install psycopg2-binary==2.8.6
modified: README.md
modified: config/.env
modified: README.md
modified: config/settings.py
(venv3932) λ mkdir apps\accounts
(venv3932) λ python manage.py startapp accounts apps/accounts
modified: README.md
modified: apps/accounts/apps.py
modified: config/settings.py
modified: README.md
modified: apps/accounts/admin.py
new file: apps/accounts/migrations/0001_initial.py
modified: apps/accounts/models.py
modified: config/settings.py
(venv3932) λ mkdir apps\category
(venv3932) λ python manage.py startapp category apps/category
modified: README.md
modified: apps/category/apps.py
modified: config/settings.py
modified: README.md
modified: apps/category/admin.py
new file: apps/category/migrations/0001_initial.py
modified: apps/category/models.py
modified: README.md
modified: apps/category/admin.py
modified: README.md
new file: photos/categories/01.png
new file: photos/categories/1.jpg
new file: photos/categories/12.jpg
new file: photos/categories/1_UEJo3RJ.jpg
new file: photos/categories/2.jpg
new file: photos/categories/3.jpg
NOTE:
Could not access the image due to the media path
modified: README.md
modified: config/settings.py
modified: config/urls.py
new file: media/photos/categories/01.png
new file: media/photos/categories/1.jpg
new file: media/photos/categories/12.jpg
new file: media/photos/categories/2.jpg
new file: media/photos/categories/3.jpg
NOTE:
1. To make images accessabel, re-insert the images
2. A media folder created automatically in the project root
(venv3932) λ mkdir apps\store
(venv3932) λ python manage.py startapp store apps/store
modified: README.md
modified: apps/store/apps.py
modified: config/settings.py
modified: README.md
modified: apps/store/admin.py
new file: apps/store/migrations/0001_initial.py
modified: apps/store/models.py
modified: README.md
modified: apps/store/models.py
modified: README.md
new file: media/photos/products/ATX-Jeans.jpg
new file: media/photos/products/Blue-Shirt.jpg
new file: media/photos/products/Great-Tshirt.jpg
new file: media/photos/products/Mavi_jeans.jpg
new file: media/photos/products/Puma-Ferrari-Shoes.jpg
new file: media/photos/products/US-Polo-Assn_Jacket.jpg
new file: media/photos/products/Wrangler-Shirt.jpg
new file: media/photos/products/jordan-true-flight-basketball-shoes.jpg
modified: README.md
modified: apps/main/views.py
modified: templates/main/inc/content.html
modified: README.md
new file: apps/store/urls.py
modified: apps/store/views.py
modified: config/urls.py
new file: templates/shared/breadcrumb.html
modified: templates/shared/header-main.html
new file: templates/store/inc/aside.html
new file: templates/store/inc/main-content.html
new file: templates/store/inc/pagination.html
new file: templates/store/store-page.html
modified: README.md
modified: apps/store/views.py
modified: templates/store/inc/main-content.html
NOTE:
1. The template showing discount price.
2. But in the model there is not discount price
NEXT> Add discount price field in the product model
modified: README.md
modified: apps/store/models.py
modified: templates/store/inc/main-content.html
modified: README.md
modified: apps/store/views.py
modified: templates/store/inc/main-content.html
# Views: Counting the products
product_count = products.count()
# Template
<span class="mr-md-auto">Found <b>{{product_count}}</b> items </span>
http://127.0.0.1:8000/store/shirts
path('<slug:category_slug>/', store_page, name='products_by_category'),
# Store_page view 2 + slug
def store_page(request,category_slug=None):
# Define categories and products are None
categories = None
products = None
# What if categories slug are NOT None or exist
# Return the slugs if they are exist, or
# return 404 error if they are not exist
if category_slug != None:
categories = get_object_or_404(Category, slug=category_slug)
products = Product.objects.filter(category=categories, is_available=True)
# Product count
product_count = products.count()
else:
# Get all the available products
products = Product.objects.all().filter(is_available=True)
# Counting the products
product_count = products.count()
# Put the available products into context dictionary
context = {
'products':products, # <-- 'products' as variable
'product_count':product_count,
}
return render(request, 'store/store-page.html', context)
modified: README.md
modified: apps/store/urls.py
modified: apps/store/views.py
modified: README.md
new file: apps/category/context_processors.py
modified: README.md
modified: config/settings.py
modified: README.md
modified: templates/shared/header-main.html
modified: README.md
modified: apps/category/models.py
modified: apps/store/urls.py
modified: README.md
modified: templates/shared/header-main.html
modified: README.md
modified: templates/store/inc/main-content.html
6.18 Retrieve and display categories in aside menu of the store page (see 6.14) and add links (see 6.16)
modified: README.md
modified: templates/store/inc/aside.html
modified: README.md
modified: templates/shared/header-main.html
modified: templates/store/inc/aside.html
NOTE:
It works with this path:http://127.0.0.1:8000/store/anything/anything/
modified: README.md
modified: apps/store/urls.py
modified: apps/store/views.py
new file: templates/store/detail-page.html
modified: templates/store/inc/main-content.html
modified: README.md
modified: apps/store/__pycache__/views.cpython-39.pyc
modified: apps/store/views.py
modified: templates/store/detail-page.html
modified: README.md
modified: apps/store/models.py
modified: templates/main/inc/content.html
modified: templates/store/inc/main-content.html
modified: README.md
modified: templates/main/inc/content.html
modified: templates/shared/header-main.html
modified: README.md
modified: apps/main/urls.py
modified: apps/store/urls.py
modified: templates/main/inc/content.html
modified: templates/shared/header-main.html
modified: templates/store/detail-page.html
modified: templates/store/inc/aside.html
modified: templates/store/inc/main-content.html
modified: README.md
new file: config/static/images/banners/cover.jpg
new file: static/images/banners/cover.jpg
modified: templates/main/inc/banner.html
modified: README.md
modified: templates/shared/head.html
modified: templates/store/detail-page.html
modified: README.md
modified: templates/store/detail-page.html
modified: README.md
modified: apps/cart/apps.py
modified: config/settings.py
new file: apps/cart/urls.py
modified: apps/cart/views.py
modified: config/urls.py
new file: templates/cart/cart-page.html
modified: README.md
modified: templates/cart/cart-page.html
modified: README.md
modified: templates/store/detail-page.html
modified: templates/store/inc/main-content.html
modified: README.md
modified: apps/cart/admin.py
new file: apps/cart/migrations/0001_initial.py
modified: apps/cart/models.py
modified: README.md
modified: apps/category/models.py
modified: apps/store/views.py
modified: templates/shared/head.html
modified: templates/store/inc/aside.html
NOTE:
1. create requirements.txt file in root dir
2. write to it
(venv3932) λ pip freeze r > requirements.txt
modified: README.md
new file: requirements.txt