根据类别显示列表(Django)

根据类别显示列表(Django),django,list,class,html,django-templates,Django,List,Class,Html,Django Templates,我有以下问题 <div class="variable"> <ul class="1"> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> </ul> <ul class="2"> <li>2</li&g

我有以下问题

<div class="variable">
<ul class="1">
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
</ul>

<ul class="2">
    <li>2</li>
    <li>2</li>
    <li>2</li>
    <li>2</li>
    <li>2</li>
</ul>

<ul class="3">
    <li>3</li>
    <li>3</li>
    <li>3</li>
    <li>3</li>
    <li>3</li>
</ul>

<ul class="4">
    <li>4</li>
    <li>4</li>
    <li>4</li>
    <li>4</li>
    <li>4</li>
</ul>

<ul class="5">
    <li>5</li>
    <li>5</li>
    <li>5</li>
    <li>5</li>
    <li>5</li>
</ul>
</div>

  • 一,
  • 一,
  • 一,
  • 一,
  • 一,
  • 二,
  • 二,
  • 二,
  • 二,
  • 二,
  • 三,
  • 三,
  • 三,
  • 三,
  • 三,
  • 四,
  • 四,
  • 四,
  • 四,
  • 四,
  • 五,
  • 五,
  • 五,
  • 五,
  • 五,
我需要的是,当“变量”是例如“1”列表只显示“1”

有可能吗

我需要根据DIV的类显示一个列表。DIV类是可变的,生成我的系统,但没有问题,因为它被设置为普通HTML

问候


升级


我在Django使用web

我有一个类别ID的列表。我想输入DIV ID,以便只显示与该数字匹配的列表

正如你评论说我不能使用数字,我必须使用名称,问题是一个名为“罗技鼠标”的类别和一个不允许我放置空格的类,有什么解决办法吗

我的Django模板是:

{% load i18n %}
{% load thumbnail %}
{% load modules %}

    {% module {category_decription|catalog.right} id="sidebar" class="block" %}
<div style="float:right; width: 700px; margin-right: 10px; margin-bottom: 10px;" id="slider">
<div><img border="0" src="/../../static/banners_productos/{{ query.id }}/01.jpg" ></img></div>
</div>

<style>
ul.marcas{
   display: none; 
}
div.SMARTPHONES ul{
   display: none; 
   color: green;
}

div.SMARTPHONES ul.SMARTPHONES{
   display: block;
}

div.FAX ul{
   display: none; 
   color: green;
}

div.FAX ul.FAX{
   display: block;
}

.fabricante { display: inline; }
</style>


    <div style="background-color:#fff;" id="content">
        <div id="catalog-category" class="block clearfix">
            <!--div class="catalog-head"-->

                <div class="toolbar toolbar-top">
                    <span style=" float: left;" class="view-mode">Productos : {{ values|length }}/{{ total }}</span>
                    <div class="items-pager">
                    <span class="items-drop"><select onchange="setLocation('paginator',this.value)">{% for item in paginator_items %}<option value="{{ item }}"{% if paginator_option == item %} selected="selected"{% endif %}>{{ item }}</option>{% endfor %}</select> Mostrar</span>
                    </div>
                    <!--div style="float: left; margin-left: 25px;"><span class="view-mode">Stock </span><a style="color:#1D9107;" href="?available=1">OK</a><a style="color:#f00;" href="?available=0">NO</a></div-->
                    <div class="items-sort">
                        <span class="sort-drop">Ordenar por
                        <select onchange="setLocation('order',this.value)">{% for order in catalog_orders %}<option value="{{ order }}"{% if order_option == order %} selected="selected"{% endif %}>{% trans order %}</option>{% endfor %}</select>
                        {% if order_by_option = 'desc' %}<a style="color:#fff; margin-left: 15px;" href="#" onclick="setLocation('order_by','asc')">Descendente<img style="height: 22px; float: right; margin-left: 4px; margin-right: 15px;"  border="0" src="/../../static/asce.png" ></img></a>{% else %}<a style="color: #FFF !important; margin-left: 15px;" href="#" onclick="setLocation('order_by','desc')">Ascendente<img style="height: 22px; float: right; margin-left: 4px; margin-right: 15px; " src="/../../static/des.png" ></img></a>{% endif %}</span>
                    </div>
                </div>
                {% if values|length == 0 %}<p class="note-msg">{% trans "No existen productos en esta categoria." %}</p>{% endif %}
            <!--/div-->
            <!--div class="catalog-body"-->
            <div style="height: 40px; margin-top: -10px; padding: 10px; height: 30px;" class="{{ query.name }}">
            <ul class="marcas FAX">
                <li class="fabricante">BROTHER</li>
            </ul>

            <ul class="marcas IMPRESORAS">
                <li class="fabricante">HP</li>
                <li class="fabricante">BROTHER</li>
                <li class="fabricante">EPSON</li>
            </ul>

            <ul class="marcas SMARTPHONES">
                <li class="fabricante">TP LINK</li>
                <li class="fabricante">TENDA</li>
                <li class="fabricante">{{ query.id }}</li>
            </ul>
            </div>      


                {% if mode_option == 'list' %}

                       <ul id="catalog-list">{% for value in values %}
                        <li id="product-{{value.product.id}}" class="product-item block clearfix">
                            <div class="product-detail">
                                <div>
                                    <a href="{{value.url}}" class="product-img"><img src="{% thumbnail value.base_image.url 150x150 product_zoook.png %}" title="{{value.name}}" /></a>
                                </div>

                            <div style="width: 420px; float: left; height: 15px; overflow: hidden;"><a href="{{value.url}}" class="product-name" alt="{{value.name}}" title="{{value.name}}"><h2>{{value.name}}</h2></a></div>
                            <div style="width: 365px; float:left;">
                                <div style="height: 35px; float:left;"></div>
                                <div style="width: 50%; float: left; height: 15px; font-size: 10px;">Ref: {{value.code}}</h2></div>
                                <div style="width: 50%; float: left; height: 15px; font-size: 10px;">Part Number: {{value.variants}}</h2></div>
                                <div style="width: 50%; float: left; height: 15px; font-size: 10px;">Categoria: {{ query.name }}</h2></div>
                                <div style="width: 110px; float: left;font-size: 10px;">
                                <a href="{{value.url}}" class="product-name" alt="{{value.name}}" title="{{value.name}}"><img style="height: 22px; float: left; margin-top: 7px;" src="../../../../static/images/info_ico.png" /></a>
                                </div>

                            </div>
                            <div style="width: 150px; float: right;">
                                             {% if value.status %}
                        {% if value.product.available %}
                        <img style="height: 15px; margin-top: -16px; margin-left: 79px; margin-bottom: 14px;" src="../../../../static/images/ok.jpg" />
                        {% else %}
                        <img style="height: 15px; margin-top: -16px; margin-left: 79px; margin-bottom: 14px;" src="../../../../static/images/ok.jpg" />
                        {% endif %}
                    {% else %}
                    </div>
                        <div class="out-service ico border3b"><h3>{% trans "This product is out of service" %}</h3></div>
                   {% endif %}
                    {% if user.is_authenticated %}
                                <div id="product-price-{{value.product.id}}" class="price-box">
                                    <span class="regular-price">
                                        <span class="price3">
                                            {% if currency_position == 'before' %}{{ currency }} {{value.price}}{% else %}{{value.price}} {{ currency }}{% endif %}
                                        </span>
                                    </span>
                                </div>

                            </div>
                    {% else %}

                    <a style="margin-right: 12px; width: 90px; float: right; height: 16px; padding: 5px; margin-top: 5px; background-image: url('/static/images/menu_pequeño/reg.jpg');" class="boton5" href="http://www.broadband-technologies.es/es/partner/login"><span style="padding-left: 20px;"></span></a>

                    {% endif %}
                        </li>{% endfor %}
                </ul>
                {% endif %}

            <!--/div--></div>
            {% if product_products.paginator.num_pages > 1 %}
            <div id="paginator" class="pagination toolbar-bottom">
                <span class="step-links">
                    {% if product_products.has_previous %}
                        <a href="{% if categories_path or tag %}?{% else %}{{ request.path }}?q={{q}}&{% endif %}page={{ product_products.previous_page_number }}">{% trans "Previous" %}</a>
                    {% endif %}
                    <span class="current">
                        {% trans "Page" %} {{ product_products.number }} DE {{ product_products.paginator.num_pages }}
                    </span>
                    {% if product_products.has_next %}
                        <a href="{% if categories_path or tag %}?{% else %}{{ request.path }}?q={{q}}&{% endif %}page={{ product_products.next_page_number }}">{% trans "Next" %}</a>
                    {% endif %}
                </span>
            </div>{% endif %}
        </div>
    <!--/div-->

<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.zproduct.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.fancybox-1.3.4.pack.js"></script>
{% if update_price and user.is_authenticated and values|length > 0 %}<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.zupdateprice.js"></script>{% endif %}
{%loadi18n%}
{%加载缩略图%}
{%load modules%}
{%module{category_description}catalog.right}id=“sidebar”class=“block”%%
马卡斯{
显示:无;
}
联邦调查司{
显示:无;
颜色:绿色;
}
智能手机分部{
显示:块;
}
传真部{
显示:无;
颜色:绿色;
}
部门传真{
显示:块;
}
.fabricante{display:inline;}
产品:{{values | length}}/{{total}
{%for paginator_items%}{{item}}{%endfor%}Mostrar中的项
奥德纳波尔酒店
{%for目录中的订单\订单%}{%trans-order%}{%endfor%}
{%if order_by_option='desc'%}{%else%}{%endif%}
{%if值| length==0%}

{%trans“不存在分类中的产品。”%}

{%endif%}
    兄弟
    惠普 兄弟 爱普生
    TP链路 坦达
  • {{query.id}
{%if mode_option=='列表'%}
    {%表示值中的值%}
  • Ref:{{value.code} 零件号:{{value.variants} 类别:{{query.name} {%if value.status%} {%if value.product.available%} {%else%} {%endif%} {%else%} {%trans“此产品已停止使用”%} {%endif%} {%if user.u经过身份验证%} {%if currency_position=='在“%${{currency}{{value.price}{{else%}{{value.price}{{currency}}{%endif%} {%else%} {%endif%}
  • {%endfor%}
{%endif%} {%如果product_products.paginator.num_pages>1%} {%if product_products.has_previous%} {%endif%} {%trans“Page”%}{{product_products.number}}DE{{product_products.paginator.num_pages} {%if product_products.has_next%} {%endif%} {%endif%} {%if update_price and user.is|u authenticated and values | length>0%}{%endif%}
您可能会得到一个类别列表?更容易的。。。是否仅显示包含类别的制造商

我的主要问题是(这就是为什么我要问代码): -我在Django有一页 -一、产品种类及生产厂家。 -当你在一个类别中时,我想列出一个拥有该类别产品的制造商名单


致以最诚挚的问候

首先,CSS类不应该是纯整数。所以我在答案中使用字母,因为数字不起作用。通常情况下,它应该更具描述性。
定义CSS规则,如:

div.a ul{
   display: none; 
   color: green;
}

div.a ul.a{
   display: block;
}

div.c ul{
   display: none; 
   color: red;
}

div.c ul.c{
   display: block;
}
这是小提琴-
color
规则只是为了标记t
{% for css_class in fancy_css_classes %}
div.{{ css_class }} ul{
   display: none; 
   color: red;
}

div.{{ css_class }} ul.{{ css_class }}{
   display: block;
}
{% endfor %}