Skip to content

Commit

Permalink
Fix display in dark theme (#13)
Browse files Browse the repository at this point in the history
* Fix display in dark theme
* Fix test case
* Fix dark mode for DALFRelatedFieldAjax
  • Loading branch information
hongquan authored Nov 7, 2024
1 parent 1835c21 commit 83e9385
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/dalf/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def media(self):
css={
'screen': (
'admin/css/vendor/select2/select2.min.css',
'admin/css/autocomplete.css',
'admin/css/django_admin_list_filter.css',
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ul>
<li>
{% with params=choices|last %}
<select class="django-admin-list-filter" name="{{ params.field_name }}" data-is-choices-filter="{{ params.is_choices_filter }}">
<select class="django-admin-list-filter admin-autocomplete" name="{{ params.field_name }}" data-is-choices-filter="{{ params.is_choices_filter }}" data-theme="admin-autocomplete">
{% for choice in choices %}
{% if choice.display %}<option value="{{ choice.query_string|iriencode }}"{% if choice.selected %} selected{% endif %}>{{ choice.display }}</option>{% endif %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
data-allow-clear="true"
data-app-label="{{ params.app_label }}"
data-model-name="{{ params.model_name }}"
data-theme="admin-autocomplete"
data-field-name="{{ params.field_name }}"></select>
{% endwith %}
</li>
Expand Down
4 changes: 2 additions & 2 deletions tests/testproject/testapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_post_admin_filters_basics(admin_client, posts): # noqa: ARG001

if option_field_name in ['author', 'audience']:
assert (
f'<select class="django-admin-list-filter" name="{option_field_name}" '
f'data-is-choices-filter="{option_is_choices_filter}">'
f'<select class="django-admin-list-filter admin-autocomplete" name="{option_field_name}" '
f'data-is-choices-filter="{option_is_choices_filter}" data-theme="admin-autocomplete">'
) in content

if option_field_name == 'author':
Expand Down

0 comments on commit 83e9385

Please sign in to comment.