I followed a walkthrough on how to set up a multifield form that can be used to query a HubDB table and it works well enough with some slight issues. I want it to work so that when only one selection is made from the options, it will still query even if the other fields are blank. Currently, all dropdown fields must be filled in order to query. I’m sure I’m missing something here that is staring me in the face!
Here is what I’ve got set up for the query:
{% set queryparam = "" %}
{% if request.query_dict.location != "" %}
{% set queryparam = queryparam+"&location__icontains="~request.query_dict.location|urlencode %}
{% endif %}
{% if request.query_dict.country !="" %}
{% set queryparam = queryparam+"&country="~request.query_dict.country|urlencode %}
{% endif %}
{% if request.query_dict.category != "" %}
{% set queryparam = queryparam+"&content__icontains="~request.query_dict.category|urlencode %}
{% endif %}
{% if request.query_dict.contact != "" %}
{% set queryparam = queryparam+"&contact_type="~request.query_dict.contact|urlencode %}
{% endif %}
Any advice on how to approach this is greatly appreciated! Thanks!