#NEWLINE# def product_details( request , slug , product_id ) : #NEWLINE# #INDENT# products = Product . objects . get_available_products ( ) . select_subclasses ( ) #NEWLINE# products = products . prefetch_related ( 'categories' , 'images' , 'variants__stock' , 'variants__variant_images__image' , 'attributes__values' ) #NEWLINE# product = get_object_or_404 ( products , id = product_id ) #NEWLINE# if ( product . get_slug ( ) != slug ) : #NEWLINE# #INDENT# return HttpResponsePermanentRedirect ( product . get_absolute_url ( ) ) #NEWLINE# #UNINDENT# form_class = get_form_class_for_product ( product ) #NEWLINE# cart = Cart . for_session_cart ( request . cart , discounts = request . discounts ) #NEWLINE# form = form_class ( cart = product , product = product , data = ( request . POST or None ) ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# form . save ( ) #NEWLINE# return redirect ( 'cart:index' ) #NEWLINE# #UNINDENT# template_name = ( 'product/details_%s.html' % ( type ( product ) . __name__ . lower ( ) , ) ) #NEWLINE# templates = [ template_name , 'product/details.html' ] #NEWLINE# return TemplateResponse ( request , templates , { #NEWLINE# #INDENT# 'product' : product , #NEWLINE# 'form' : form , #NEWLINE# #UNINDENT# } )