Mani
Then share this
@login_required (login_url = 'login')
def checkout(request):
sub_total = 0
total = 0
quantity = 0
total_count_in_cart = 0
tax = 0
try:
cart_items = CartItem.objects.filter(user=request.user,is_active=True)
for cartitem in cart_items:
print (cartitem.product.name)
sub_total += (cartitem.product.price * cartitem.quantity)
quantity += cartitem.quantity
tax = sub_total * 0.02
total = sub_total + tax
except ObjectDoesNotExist:
pass
first_name = request.user.first_name
last_name = request.user.last_name
user_email = request.user.email
context = {
"sub_total":sub_total,
"tax":tax,
"total":total,
"total_count_in_cart":total_count_in_cart,
"first_name":first_name,
"last_name": last_name,
"user_email": user_email,
}
return render(request, 'store/checkout.html', context)
Enes
[{"model": "store.product", "pk": 3, "fields": {"name": "Men Shoe", "photo": "products/480...jpg", "photo2": "", "photo3": "", "photo4": "", "photo5": "", "price": 256, "old_price": 534, "details": "These shoes are really cool!", "category": 3, "is_draft": false, "date": "2021-07-15T16:03:14.438Z"}}, {"model": "store.product", "pk": 2, "fields": {"name": "T-Shirt & Jacket", "photo": "products/480..jpg", "photo2": "", "photo3": "", "photo4": "", "photo5": "", "price": 68, "old_price": 534, "details": "These products are comfortable and not ichy", "category": 2, "is_draft": false, "date": "2021-07-15T16:01:50.045Z"}}, {"model": "store.product", "pk": 1, "fields": {"name": "Women's Watch", "photo": "products/..480.jpg", "photo2": "images/items/2021/07/16/00/26/12/.480.jpg", "photo3": "", "photo4": "", "photo5": "", "price": 459, "old_price": 534, "details": "These women's watches are really famous. You can wear even in everywhere.", "category": 1, "is_draft": false, "date": "2021-07-04T16:25:00.463Z"}}]
Almaz
Hello, everyone! I need help:
I have noattributeerror at, although i provided all urls, views and templates. The names of urls also correct. I've been stuck at it for hours and i don't know how to solve this problem
Damilola
Guys what do you think about
Django + Firebase
Versus
Django + Postgresql
I think psql is robust, feels enterprise level or dare I say production grade.
Firebase on the other hand feels fast, lightweight and unreliable in terms of data integrity.
Feel free to share your thoughts.
Anonymous
hello, what's the problem here, error message 'ItemAdmin' object has no attribute 'urls', https://pastebin.com/Wtfz3hMN, https://pastebin.com/ci8pxb5W
SOSO
Hi guys!
Can anyone help me to ranmdomize QuerySet?
pharmacy_employees = PharmacyEmployee.objects.all().filter(pharmacy=ph.pharmacy, date=ph.date)
count = ph.number_of_employees
rand_employees = random.sample(pharmacy_employees, count)
Error:
rand_employees = random.sample(pharmacy_employees, count)
IndentationError: unexpected indent
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like:
- https://del.dog
- https://dpaste.org
- https://linkode.org
- https://hastebin.com
- https://bin.kv2.dev
If you posted a wall of text, go back and delete it.