Skip to content

Adding django filters - #835

Open
Sahil590 wants to merge 4 commits into
mainfrom
filters
Open

Sahil590 wants to merge 4 commits into
mainfrom
filters

Conversation

@Sahil590

@Sahil590 Sahil590 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

I followed the django filter docs to replace the existing hard coed search implementation. I was going to attempt adding htmx to have the search results appear as you type in a different PR.

I did use copilot for the tests and docstrings.
Fixes #798 (issue)

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Technical work (non-breaking, change which is work as part of a new feature)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass (eg. python -m pytest)
  • The documentation builds and looks OK (eg. mkdocs serve)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))

@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The production requirements omit django-filter, so adding django_filters to INSTALLED_APPS causes Docker’s collectstatic step to fail with ModuleNotFoundError and blocks production image builds.

1 open issue
What changed in this PR

Replaces the learning-resource page’s manual search filtering with django-filter, adopting the table-filtering approach requested in #798.

Changes:

  • Moves cross-field search into LearningResourceFilter and integrates it with the table view.
  • Renders the search field with crispy forms, preserves sorting on submission, and adds a reset link.
  • Adds filtering and pagination tests, plus dependency and tooling configuration.
File Description
tests/​main/​test_main_views.py Tests the search form, empty results, sorting, and pagination.
tests/​main/​test_filters.py Tests field matching, whitespace handling, and duplicate prevention.
requirements.txt Adds django-filter to runtime dependencies.
pyproject.toml Declares django-filter and its mypy override.
main/​views/​page_views.py Integrates FilterView with the learning-resource table.
main/​templates/​main/​pages/​learning-resources.html Renders the filter field and adds sorting preservation and reset.
main/​filters.py Defines the cross-field learning-resource search filter.
doc-requirements.txt Updates documentation dependencies to include django-filter.
direct_webapp/​settings/​settings.py Registers django-filter in installed apps.
dev-requirements.txt Updates development dependencies to include django-filter.
.pre-commit-config.yaml Adds django-filter to the mypy hook environment.

Review effort: Balanced

Comment thread direct_webapp/settings/settings.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use Django-filter for filtering tables

2 participants