Django/jquery sorting list by max count

Django/jquery sorting list by max count

Postby mhashmi » Wed Aug 03, 2016 4:22 pm

Hi,
Following is the code in html file:

Code: Select all
{% load hitcount_tags %}
{% for product in product %}
    <div class="thumbnail col-sm-2 col-xs-3 .col-sm-2 ">
           <a href="{{ product.get_absolute_url }}"><h5><b>{{ product.title }}</b><br /></h5></a>
            {% if product.get_image_url %}
                <a href="{{ product.get_absolute_url }}"><img class="img-responsive" src="{{ product.get_image_url }}"/></a><br/>
            {% endif %}

        <p class="view" data-hits="{% get_hit_count for product %}" data-id="{{ product.pk }}">Views:{% get_hit_count for product %}</p>

        {% if price == 'True' %}
        {{ product.variation_set.first.get_html_price|safe }}
        {% endif %}

By inspecting elements it is showing me like:

Code: Select all
<div class="thumbnail col-sm-2 col-xs-3 .col-sm-2 ">
           <a href="/products/7/"><h5><b>Best Dress Fashion</b><br></h5></a>
                <a href="/products/7/"><img class="img-responsive" src="/media/products/best-dress-fashion/best-dress-fashion-5.jpg"></a><br>
    <p class="view" data-hits="2" data-id="7">Views:2</p>
  </div>


I need javascript/jquery sorting function to sort all products by max count. Please refer some best practices link. Number of hits variable for jquery is
Code: Select all
data-hits
as shown and product id variable is
Code: Select all
data-id
. Any suggestions?
Last edited by Mekire on Wed Aug 03, 2016 5:20 pm, edited 1 time in total.
Reason: First post lock.
mhashmi
 
Posts: 1
Joined: Wed Aug 03, 2016 4:07 pm

Re: Django/jquery sorting list by max count

Postby Ofnuts » Wed Aug 03, 2016 5:37 pm

Maybe ask in a Javascript forum? Here we deal with Python code.
This forum has been moved to http://python-forum.io/. See you there.
User avatar
Ofnuts
 
Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron