We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class ViewCart(TemplateView): template_name = 'cart/view_cart.html'
def get_context_data(self,request,**kwargs): context = super().get_context_data(request,**kwargs) try: the_id = request.session['cart_id'] except: the_id = None if the_id: cart = Cart.objects.get(id = the_id) context['cart'] = cart context['empty'] = False else: empty_message = "Your Cart is Sad!, please keep shopping." context['empty'] = True context['empty_message'] = empty_message return context
The text was updated successfully, but these errors were encountered:
Try this it might be of help to you:
class ViewCart(TemplateView): template_name = 'cart/view_cart.html' def get_context_data(self,**kwargs): context = super(ViewCart, self).get_context_data() try: the_id = self.kwargs['cart_id'] except: the_id = None if the_id: cart = Cart.objects.get(id = the_id) context['cart'] = cart context['empty'] = False else: empty_message = "Your Cart is Sad!, please keep shopping." context['empty'] = True context['empty_message'] = empty_message return context
Sorry, something went wrong.
get_context_data is in your class view which already has "request", so you don't need to wait for it in this method you can call it by self.request
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) try: the_id = self.request.session['cart_id']
No branches or pull requests
class ViewCart(TemplateView):
template_name = 'cart/view_cart.html'
The text was updated successfully, but these errors were encountered: