Are you not using class ?
On Tue, Sep 4, 2018 at 6:44 PM carl collins <carlcollinswayig@gmail.com> wrote:
Here is the code for view.py in my cart app please help(also see the screenshot):--from django.template import loaderfrom django.http import HttpResponsefrom django.template.loader import render_to_stringimport django.template.loaderfrom cart.cart import Cartfrom .models import Product'''from cart.models import Category, Product'''#gallery default viewdef index(request):#prepare the models# empty#prepare the templatetemplate = loader.get_template('templates/cart.html', dict(cart=Cart(request)) )#prepare the contextcontext = {'request':request}return HttpResponse(template.render(context, request))def add_to_cart(request, product_id, quantity):product = Product.objects.get(id=product_id)cart = Cart(request)cart.add(product, product.unit_price, quantity)def remove_from_cart(request, product_id):product = Product.objects.get(id=product_id)cart = Cart(request)cart.remove(product)def get_cart(request):template = loader.get_template('templates/cart.html', dict(cart = Cart(request)))#prepare the contextcontext = {'request':request}return HttpResponse(template.render(context, request))return HttpResponse(template.render(context, request))
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a78552f7-9973-456d-b0d5-79602f4bbf5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUfoUms07suSkNJuCCZMjn3iHAwqyonerU1K%2BE%3Dc%2B43m6w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment