Skip to content

Commit

Permalink
Add DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Oct 28, 2024
1 parent ea83926 commit 80335b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ in the ``DJANGOCMS_LINKABLE_MODELS`` setting using dotted strings::

Attention: ``Page`` objects are always linkable.

Large search-sets
..................

If you have a large number of internally linkable models, you can use the
``DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH`` setting to require a minimum number of
characters typed before the search is triggered. The default is 0::

# Require at least 2 characters to be typed before searching for pages
DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH = 2

Non-standard hostnames
......................

Expand Down
3 changes: 2 additions & 1 deletion djangocms_link/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


MINIMUM_INPUT_LENGTH = getattr(
settings, "DJANGOCMS_LINK_SELECT2_MINIMUM_INPUT_LENGTH", 0
settings, "DJANGOCMS_LINK_MINIMUM_INPUT_LENGTH", 0
)


Expand Down Expand Up @@ -91,6 +91,7 @@ def build_attrs(self, base_attrs, extra_attrs=None):
"data-theme": "admin-autocomplete",
"data-allow-clear": json.dumps(not self.is_required),
"data-placeholder": "", # Allows clearing of the input.
"data-minimum-input-length": MINIMUM_INPUT_LENGTH,
"lang": i18n_name,
"class": attrs["class"]
+ (" " if attrs["class"] else "")
Expand Down

0 comments on commit 80335b5

Please sign in to comment.