mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #35598 -- Added SearchInput widget.
This commit is contained in:
parent
3f88089069
commit
30a60e8492
1
AUTHORS
1
AUTHORS
@ -495,6 +495,7 @@ answer newbie questions, and generally made Django that much better:
|
|||||||
Jeremy Carbaugh <jcarbaugh@gmail.com>
|
Jeremy Carbaugh <jcarbaugh@gmail.com>
|
||||||
Jeremy Dunck <jdunck@gmail.com>
|
Jeremy Dunck <jdunck@gmail.com>
|
||||||
Jeremy Lainé <jeremy.laine@m4x.org>
|
Jeremy Lainé <jeremy.laine@m4x.org>
|
||||||
|
Jeremy Thompson <https://jhthompson.ca>
|
||||||
Jerin Peter George <jerinpetergeorge@gmail.com>
|
Jerin Peter George <jerinpetergeorge@gmail.com>
|
||||||
Jesse Young <adunar@gmail.com>
|
Jesse Young <adunar@gmail.com>
|
||||||
Jezeniel Zapanta <jezeniel.zapanta@gmail.com>
|
Jezeniel Zapanta <jezeniel.zapanta@gmail.com>
|
||||||
|
1
django/forms/jinja2/django/forms/widgets/search.html
Normal file
1
django/forms/jinja2/django/forms/widgets/search.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
{% include "django/forms/widgets/input.html" %}
|
1
django/forms/templates/django/forms/widgets/search.html
Normal file
1
django/forms/templates/django/forms/widgets/search.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
{% include "django/forms/widgets/input.html" %}
|
@ -30,6 +30,7 @@ __all__ = (
|
|||||||
"NumberInput",
|
"NumberInput",
|
||||||
"EmailInput",
|
"EmailInput",
|
||||||
"URLInput",
|
"URLInput",
|
||||||
|
"SearchInput",
|
||||||
"PasswordInput",
|
"PasswordInput",
|
||||||
"HiddenInput",
|
"HiddenInput",
|
||||||
"MultipleHiddenInput",
|
"MultipleHiddenInput",
|
||||||
@ -353,6 +354,11 @@ class URLInput(Input):
|
|||||||
template_name = "django/forms/widgets/url.html"
|
template_name = "django/forms/widgets/url.html"
|
||||||
|
|
||||||
|
|
||||||
|
class SearchInput(Input):
|
||||||
|
input_type = "search"
|
||||||
|
template_name = "django/forms/widgets/search.html"
|
||||||
|
|
||||||
|
|
||||||
class PasswordInput(Input):
|
class PasswordInput(Input):
|
||||||
input_type = "password"
|
input_type = "password"
|
||||||
template_name = "django/forms/widgets/password.html"
|
template_name = "django/forms/widgets/password.html"
|
||||||
|
@ -558,6 +558,17 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
|
|||||||
* ``template_name``: ``'django/forms/widgets/url.html'``
|
* ``template_name``: ``'django/forms/widgets/url.html'``
|
||||||
* Renders as: ``<input type="url" ...>``
|
* Renders as: ``<input type="url" ...>``
|
||||||
|
|
||||||
|
``SearchInput``
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. versionadded:: 5.2
|
||||||
|
|
||||||
|
.. class:: SearchInput
|
||||||
|
|
||||||
|
* ``input_type``: ``'search'``
|
||||||
|
* ``template_name``: ``'django/forms/widgets/search.html'``
|
||||||
|
* Renders as: ``<input type="search" ...>``
|
||||||
|
|
||||||
``PasswordInput``
|
``PasswordInput``
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -165,7 +165,8 @@ File Uploads
|
|||||||
Forms
|
Forms
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
* ...
|
* The new :class:`~django.forms.SearchInput` form widget is for entering search
|
||||||
|
queries and renders as ``<input type="search" ...>``.
|
||||||
|
|
||||||
Generic Views
|
Generic Views
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
|
12
tests/forms_tests/widget_tests/test_searchinput.py
Normal file
12
tests/forms_tests/widget_tests/test_searchinput.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from django.forms import SearchInput
|
||||||
|
|
||||||
|
from .base import WidgetTest
|
||||||
|
|
||||||
|
|
||||||
|
class SearchInputTest(WidgetTest):
|
||||||
|
widget = SearchInput()
|
||||||
|
|
||||||
|
def test_render(self):
|
||||||
|
self.check_html(
|
||||||
|
self.widget, "search", "", html='<input type="search" name="search">'
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user