Hello there! I want to be able to have my states listed Alphabetically. Since there is no drag and drop feature on HubDB table, I would have to filter and code it out myself…
Here is my filter code:
{% set queryparam = "" %}
{% if request.query_dict.state in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"] and request.query_dict.name == "" %}
{% set queryparam = queryparam ~ "&state=__contains"~request.query_dict.state|urlencode %}
{% endif %}
{% if request.query_dict.state in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"] and request.query_dict.name != "" %}
{% set queryparam = queryparam~"&state="~request.query_dict.state|urlencode~"&zip__icontains="~request.query_dict.zip|urlencode %}
{% endif %}
{% if request.query_dict.state == "show-all" and request.query_dict.name != "" %}
{% endif %}
Here is the code to render data:
<!-- Check if table exists, set sort by state -->
{% if table == [] %}
<p class='align-center'>Sorry, no listings found for that search. Try changing your filter and search again.</p>
{% else %}
{% for row in table|sort(False, False, 'state') %}
<div class="consultant-listing">
<h4>{{ row["name"] }}</h4>
<div class="information">
{% for state in row.state %}
<div class="fac_state">{{state.name }}
</div>
{% endfor %}
<div class="fac_city"">{{ row["city"] }} , {{ row["zip"] }}</div>
<div class='location_details'> Locations: {{row["location"]}}</div>
<div><i class="fas fa-phone"></i> {{ row["phone"] }}</div>
<br><div class="links"> <i class="fas fa-link"></i> <a href="{{row["website"]}}">Website</a>
<br><i class="fas fa-envelope"></i> <a href="mailto:{{ row["email"] }}">{{ row["email"] }}</a>
</div>
{#<div class="location_details">{{ row["location_details"] }}</div>#}
</div>
</div>
{% endfor %}
{% endif %}</div>
This is the page. I want the states to be in alphabetical order:
Thank you so much ![]()


