-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Documented ObjectListView quick search feature for plugins #20500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the doc additions, @991jo . It's much appreciated!
I made some notes here and below:
- Let's clarify that the "Quick Search" field is the UI field, not the field in the filter or the method name.
- Your sentences appear to all be on a separate line, is there some reason to not have them on the same line and let MkDocs figure out the wrapping?
Q(description__icontains=value) | ||
) | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things that I think are worth mentioning:
NetBoxModelFilterSet.search()
is already implemented and just returns the queryset unmodified, which is why it needs to be over-ridden here.- For context, the
search()
method is called as a result of theq
filter, which is already wire up inNetBoxModelFilterSet
and does not need to be over-ridden here unless different behavior is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I incorporated your comments in 6593f1b
Co-authored-by: Jason Novinger <[email protected]>
Regarding each sentence being on it's own line: That's mainly a convention I am sticking to, because it makes changes in diffs clearer, because you only get 1 sentence highlighted instead of the whole paragraph. Regarding the control of linebreaks: It is complicated. This is primarily an issue of Markdown. CommonMark (an attempt at a markdown spec) seperates a paragraph only if there is a blank line inbetween (see https://spec.commonmark.org/0.31.2/#paragraphs ). For me this generates one <p>The <code>ObjectListView</code> has a field called Quick Search.
For Quick Search to work the corresponding FilterSet has to implement the <code>search</code> method.
This function takes a queryset and can perform arbitrary operations on it and return it.
A common use-case is to search for the given search value in multiple fields:</p> -> there is no special line break handling in mkdocs afaik and it's all HTML or whatever the other output options of mkdocs are. |
Fixes: #20499