26.机构模块——机构列表页面按机构类别,城市进行联合筛选过滤

#按照机构类别进行过滤筛选orgs/views.py
    cate = request.GET.get('cate','')
    if cate:
        all_orgs = all_orgs.filter(category=cate)

#按照所在地区进行过滤筛选
    cityid = request.GET.get('cityid','')
    if cityid:
        all_orgs = all_orgs.filter(cityinfo_id=int(cityid))

    'sort_orgs':sort_orgs,
    'cityid':cityid,
<ul class="pagelist">
    {% if pages.has_previous %}
    <li class="long"><a href="?pagenum={{ pages.previous_page_number }}&cate={{ cate }}&cityid={{ cityid }}&sort={{ sort }}&keyword={{ keyword }}">上一页</a></li>
    {% endif %}

    {% for num in pages.paginator.page_range %}
    <li {% if num == pages.number %}class="active"{% endif %}><a href="?pagenum={{ num }}&cate={{ cate }}&cityid={{ cityid }}&sort={{ sort }}&keyword={{ keyword }}">{{ num }}</a></li>
    {% endfor %}

    {% if pages.has_next %}
    <li class="long"><a href="?pagenum={{ pages.next_page_number }}&cate={{ cate }}&cityid={{ cityid }}&sort={{ sort }}&keyword={{ keyword }}">下一页</a></li>
    {% endif %}
/ul>


<h2>机构类别</h2>
	<div class="cont">
        <a href="?&cityid={{ cityid }}&sort={{ sort }}"><span {% if cate == '' %}class="active2"{% endif %}>全部</span></a>
        <a href="?cate=pxjg&cityid={{ cityid }}&sort={{ sort }}"><span {% if cate == 'pxjg' %}class="active2"{% endif %}>培训机构</span></a>
        <a href="?cate=gx&cityid={{ cityid }}&sort={{ sort }}"><span {% if cate == 'gx' %}class="active2"{% endif %}>高校</span></a>
        <a href="?cate=gr&cityid={{ cityid }}&sort={{ sort }}"><span {% if cate == 'gr' %}class="active2"{% endif %}>个人</span></a>
	</div>


<div class="cont">
    <a href="?&cate={{ cate }}&sort={{ sort }}"><span {% if cityid == '' %}class="active2"{% endif %}>全部</span></a>
    {% for city in all_citys %}
    <a href="?cityid={{ city.id }}&cate={{ cate }}&sort={{ sort }}"><span {% if cityid == city.id|stringformat:"i" %}class="active2"{% endif %}>{{ city.name }}</span></a>
    {% endfor %}

猜你喜欢

转载自blog.csdn.net/qq_36227329/article/details/89412779