0
Das Problem, das ich hier bin vor über ist, dass ich nicht in der Lage bin, die cartempty Seite, um zu sehen, wenn Elemente zählen ist 0. hier ist die AnsichtWie mit Ajax django umleiten
if request.is_ajax():
if request.POST.get('action') == 'remove':
cart_item.delete()
if cart_item.cart.items.count() == 0:
return render(request , "carts/cartempty.html", {})
else:
try:
total = cart_item.line_item_total
except:
total = None
try:
original_total = cart_item.cart.original_total
except:
original_total = None
try:
final_total = cart_item.cart.final_total
except:
final_total = None
try:
total_items = cart_item.cart.items.count()
except:
total_items = 0
data = {
"line_total": total,
"original_total": original_total,
"final_total" :final_total,
"total_items": total_items
}
return JsonResponse(data)
Wie kann ich umleiten Cartempty Seite mit Ajax?
Eine doppelte Rückkehr? Der zweite wird niemals ausgeführt werden. – Anonymous
Hahahaha, LOL. Sind Sie im Ernst? Ich schlug einen von beiden vor. Also habe ich meine Antwort bearbeitet. Es tut uns leid... –