python - Django show product detail in POPUP using ajax,jquery -
i new learn in django-ajax . don't no how use popup ajax in django view. create 2 html files list.html
, detail.html
.
my question when open list.html
whenever click on product show product details using popup format using ajax.
so please tell changes required in view, jquery, html , ajax
view.py
def show_product(request, product_slug, template_name="catalog/product.html"): p = get_object_or_404(product, slug=product_slug) categories = p.categories.filter(is_active=true) page_title = p.name meta_keywords = p.meta_keywords meta_description = p.meta_description return render_to_response(template_name, locals(),context) def list_product(request): queryset_list = product.objects.all() #.order_by("-timestamp") paginator = paginator(queryset_list, 1) # show 25 contacts per page page_request_var = "page" page = request.get.get(page_request_var) try: queryset = paginator.page(page) except pagenotaninteger: # if page not integer, deliver first page. queryset = paginator.page(1) except emptypage: # if page out of range (e.g. 9999), deliver last page of results. queryset = paginator.page(paginator.num_pages) context = { "object_list": queryset, "name": "list", "page_request_var": page_request_var } return render(request, "catalog/list.html", context)
list.html
{% extends "base.html" %} {% block content %} <div class="signup"> <div class='col-sm-6 col-sm-offset-3'> <center><h1>{{ name }}</h1></center> {% obj in object_list %} <div class="caption"> <h3>{{ obj.name }}</h3> <p>{{ obj.content|linebreaks|truncatechars:120 }}</p> <p><a href="{{ obj.get_absolute_url }}" class="btn btn-primary" role="button">view</a></p> </div> <hr/> {% endfor %} <div class="pagination"> <span class="step-links"> {% if object_list.has_previous %} <a href="?{{ page_request_var }}={{ object_list.previous_page_number }}">previous</a> {% endif %} <span class="current"> page {{ object_list.number }} of {{ object_list.paginator.num_pages }}. </span> {% if object_list.has_next %} <a href="?{{ page_request_var }}={{ object_list.next_page_number }}">next</a> {% endif %} </span> </div> </div> {% endblock content %}
product.html
{% extends "base.html" %} {% block content %} <body> <div class="signup"> <h1>{{ p.name }}</h1> brand: <em>{{ p.brand }}</em> <br/><br/> sku: {{ p.sku }} <br/> <br/> in categor{{ categories.count|pluralize:"y,ies" }}: {% c in categories %} <a href="{{ c.get_absolute_url }}">{{ c.name }}</a> {% if not forloop.last %}, {% endif %} {% endfor %} <br/><br/> {% if p.sale_price %} was: <del>$ {{ p.old_price }}</del> <br/> now: $ {{ p.price }} {% else %} price: $ {{ p.price }} {% endif %} <br/><br/> <div class="cb"><br /><br/></div> <h3>product description</h3> {{ p.description }} </div> </body> {% endblock content %}
Comments
Post a Comment