Add template hooks to all filters for customizable UIs (dropdowns, sliders, etc.)#970
Open
fd-oncodna wants to merge 4 commits intosmithyhq:mainfrom
Open
Add template hooks to all filters for customizable UIs (dropdowns, sliders, etc.)#970fd-oncodna wants to merge 4 commits intosmithyhq:mainfrom
fd-oncodna wants to merge 4 commits intosmithyhq:mainfrom
Conversation
mmzeynalli
requested changes
Dec 9, 2025
Member
mmzeynalli
left a comment
There was a problem hiding this comment.
Nice work! Do please update the mentioned part. Also, would be nice if you provided screenshots of vanilla vs custom design filter design, even if minimal.
| filter.template | ||
| if filter.template is defined and filter.template | ||
| else ( | ||
| "sqladmin/filters/operation_filter.html" |
Member
There was a problem hiding this comment.
I think we can skip this part. If user creates new filter, they will inherit the existing one, if they create from scratch, it should be their responsibility. No need for extra has_operator check.
Author
Member
Author
|
Hi everyone, happy new year! Any reason why this is not merged yet? |
Member
|
Hey! @aminalaee seems to be busy lately. I have been trying to help him with reviews and stuff, but still, merging is on his hands. |
mmzeynalli
referenced
this pull request
in mmzeynalli/sqladmin-ng
Mar 29, 2026
Add template hooks to all filters for customizable UIs (dropdowns, sliders, etc.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Overview
This PR introduces customizable filter templates by adding a
templateattribute to filters. All built-in filters now define a default template to ensure full backward compatibility.Filters are rendered through their declared template, with predictable fallbacks, making template overrides a first-class extension point.
Goals
Example
filters/status_dropdown_filter.html{% extends "sqladmin/filters/base_filter.html" %} {% block filter_body %} {% set current_value = request.query_params.get(filter.parameter_name, '') %} <form method="get" class="d-flex flex-column" style="gap: 8px;"> {% for key, value in request.query_params.items() %} {% if key != filter.parameter_name %} <input type="hidden" name="{{ key }}" value="{{ value }}"> {% endif %} {% endfor %} <select name="{{ filter.parameter_name }}" class="form-select form-select-sm"> {% for value, label in filter.lookups(request, model_view.model, model_view._run_arbitrary_query) %} <option value="{{ value }}" {% if current_value == value %}selected{% endif %}>{{ label }}</option> {% endfor %} </select> <div class="d-flex align-items-center" style="gap: 8px;"> <button type="submit" class="btn btn-sm btn-outline-primary">Apply</button> {% if current_value %} <a href="{{ request.url.remove_query_params(filter.parameter_name) }}" class="text-decoration-none small">Clear</a> {% endif %} </div> </form> {% endblock %}By subclassing an existing filter and overriding only its template, developers can package and reuse bespoke filter widgets with minimal effort.