summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/howto/static-files/index.txt2
-rw-r--r--docs/intro/contributing.txt4
-rw-r--r--docs/intro/overview.txt2
-rw-r--r--docs/intro/tutorial04.txt6
-rw-r--r--docs/intro/tutorial06.txt2
-rw-r--r--docs/ref/class-based-views/generic-editing.txt8
-rw-r--r--docs/ref/contrib/admin/index.txt2
-rw-r--r--docs/ref/forms/api.txt222
-rw-r--r--docs/ref/forms/fields.txt50
-rw-r--r--docs/ref/forms/widgets.txt34
-rw-r--r--docs/ref/request-response.txt2
-rw-r--r--docs/ref/templates/builtins.txt22
-rw-r--r--docs/ref/templates/language.txt4
-rw-r--r--docs/releases/2.1.txt4
-rw-r--r--docs/topics/auth/default.txt4
-rw-r--r--docs/topics/forms/formsets.txt66
-rw-r--r--docs/topics/forms/index.txt10
-rw-r--r--docs/topics/forms/media.txt32
-rw-r--r--docs/topics/forms/modelforms.txt14
-rw-r--r--docs/topics/i18n/timezones.txt2
-rw-r--r--docs/topics/i18n/translation.txt12
-rw-r--r--docs/topics/pagination.txt2
-rw-r--r--docs/topics/testing/tools.txt2
23 files changed, 256 insertions, 252 deletions
diff --git a/docs/howto/static-files/index.txt b/docs/howto/static-files/index.txt
index 847e3c9c19..bff1a5daa1 100644
--- a/docs/howto/static-files/index.txt
+++ b/docs/howto/static-files/index.txt
@@ -30,7 +30,7 @@ Configuring static files
.. code-block:: html+django
{% load static %}
- <img src="{% static "my_app/example.jpg" %}" alt="My image"/>
+ <img src="{% static "my_app/example.jpg" %}" alt="My image">
4. Store your static files in a folder called ``static`` in your app. For
example ``my_app/static/my_app/example.jpg``.
diff --git a/docs/intro/contributing.txt b/docs/intro/contributing.txt
index 07d9aae379..ef44c81600 100644
--- a/docs/intro/contributing.txt
+++ b/docs/intro/contributing.txt
@@ -535,8 +535,8 @@ Use the arrow keys to move up and down.
+++ b/docs/ref/forms/api.txt
@@ -1065,3 +1065,13 @@ You can put several Django forms inside one ``<form>`` tag. To give each
>>> print(father.as_ul())
- <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name" /></li>
- <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name" /></li>
+ <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name"></li>
+ <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name"></li>
+
+The prefix can also be specified on the form class::
+
diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt
index f6e34b0695..7cf17ba376 100644
--- a/docs/intro/overview.txt
+++ b/docs/intro/overview.txt
@@ -307,7 +307,7 @@ Here's what the "base.html" template, including the use of :doc:`static files
<title>{% block title %}{% endblock %}</title>
</head>
<body>
- <img src="{% static "images/sitelogo.png" %}" alt="Logo" />
+ <img src="{% static "images/sitelogo.png" %}" alt="Logo">
{% block content %}{% endblock %}
</body>
</html>
diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt
index 6f685fc402..8e1f8d9aef 100644
--- a/docs/intro/tutorial04.txt
+++ b/docs/intro/tutorial04.txt
@@ -22,10 +22,10 @@ tutorial, so that the template contains an HTML ``<form>`` element:
<form action="{% url 'polls:vote' question.id %}" method="post">
{% csrf_token %}
{% for choice in question.choice_set.all %}
- <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
- <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
+ <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
+ <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
{% endfor %}
- <input type="submit" value="Vote" />
+ <input type="submit" value="Vote">
</form>
A quick rundown:
diff --git a/docs/intro/tutorial06.txt b/docs/intro/tutorial06.txt
index 0d3dd23315..231ae315ee 100644
--- a/docs/intro/tutorial06.txt
+++ b/docs/intro/tutorial06.txt
@@ -70,7 +70,7 @@ Next, add the following at the top of ``polls/templates/polls/index.html``:
{% load static %}
- <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />
+ <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">
The ``{% static %}`` template tag generates the absolute URL of static files.
diff --git a/docs/ref/class-based-views/generic-editing.txt b/docs/ref/class-based-views/generic-editing.txt
index 65cd772536..8c1fe0f758 100644
--- a/docs/ref/class-based-views/generic-editing.txt
+++ b/docs/ref/class-based-views/generic-editing.txt
@@ -76,7 +76,7 @@ editing content:
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
- <input type="submit" value="Send message" />
+ <input type="submit" value="Send message">
</form>
@@ -132,7 +132,7 @@ editing content:
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
- <input type="submit" value="Save" />
+ <input type="submit" value="Save">
</form>
``UpdateView``
@@ -189,7 +189,7 @@ editing content:
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
- <input type="submit" value="Update" />
+ <input type="submit" value="Update">
</form>
``DeleteView``
@@ -240,5 +240,5 @@ editing content:
<form action="" method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
- <input type="submit" value="Confirm" />
+ <input type="submit" value="Confirm">
</form>
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index c043561f17..39c02f26af 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1180,7 +1180,7 @@ subclass::
# for each line of the address and you want to separate each
# line by a linebreak
return format_html_join(
- mark_safe('<br/>'),
+ mark_safe('<br>'),
'{}',
((line,) for line in instance.get_full_address()),
) or mark_safe("<span class='errors'>I can't determine this address.</span>")
diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt
index 5e001a2f62..bafa688f98 100644
--- a/docs/ref/forms/api.txt
+++ b/docs/ref/forms/api.txt
@@ -255,9 +255,9 @@ precedence::
... comment = forms.CharField()
>>> f = CommentForm(initial={'name': 'instance'}, auto_id=False)
>>> print(f)
- <tr><th>Name:</th><td><input type="text" name="name" value="instance" required /></td></tr>
- <tr><th>Url:</th><td><input type="url" name="url" required /></td></tr>
- <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr>
+ <tr><th>Name:</th><td><input type="text" name="name" value="instance" required></td></tr>
+ <tr><th>Url:</th><td><input type="url" name="url" required></td></tr>
+ <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr>
.. method:: Form.get_initial_for_field(field, field_name)
@@ -322,10 +322,10 @@ You can alter the field of :class:`Form` instance to change the way it is
presented in the form::
>>> f.as_table().split('\n')[0]
- '<tr><th>Name:</th><td><input name="name" type="text" value="instance" required /></td></tr>'
+ '<tr><th>Name:</th><td><input name="name" type="text" value="instance" required></td></tr>'
>>> f.fields['name'].label = "Username"
>>> f.as_table().split('\n')[0]
- '<tr><th>Username:</th><td><input name="name" type="text" value="instance" required /></td></tr>'
+ '<tr><th>Username:</th><td><input name="name" type="text" value="instance" required></td></tr>'
Beware not to alter the ``base_fields`` attribute because this modification
will influence all subsequent ``ContactForm`` instances within the same Python
@@ -334,7 +334,7 @@ process::
>>> f.base_fields['name'].label = "Username"
>>> another_f = CommentForm(auto_id=False)
>>> another_f.as_table().split('\n')[0]
- '<tr><th>Username:</th><td><input name="name" type="text" value="class" required /></td></tr>'
+ '<tr><th>Username:</th><td><input name="name" type="text" value="class" required></td></tr>'
Accessing "clean" data
======================
@@ -438,10 +438,10 @@ simply ``print`` it::
>>> f = ContactForm()
>>> print(f)
- <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required /></td></tr>
- <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required /></td></tr>
- <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" /></td></tr>
+ <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required></td></tr>
+ <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required></td></tr>
+ <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself"></td></tr>
If the form is bound to data, the HTML output will include that data
appropriately. For example, if a field is represented by an
@@ -455,10 +455,10 @@ include ``checked`` if appropriate::
... 'cc_myself': True}
>>> f = ContactForm(data)
>>> print(f)
- <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" value="hello" required /></td></tr>
- <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" value="Hi there" required /></td></tr>
- <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" value="foo@example.com" required /></td></tr>
- <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" checked /></td></tr>
+ <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" value="hello" required></td></tr>
+ <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" value="Hi there" required></td></tr>
+ <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" value="foo@example.com" required></td></tr>
+ <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" checked></td></tr>
This default output is a two-column HTML table, with a ``<tr>`` for each field.
Notice the following:
@@ -506,12 +506,12 @@ containing one field::
>>> f = ContactForm()
>>> f.as_p()
- '<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required /></p>\n<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required /></p>\n<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" required /></p>\n<p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p>'
+ '<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required></p>\n<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required></p>\n<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" required></p>\n<p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself"></p>'
>>> print(f.as_p())
- <p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required /></p>
- <p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required /></p>
- <p><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required /></p>
- <p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p>
+ <p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required></p>
+ <p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required></p>
+ <p><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required></p>
+ <p><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself"></p>
``as_ul()``
-----------
@@ -525,12 +525,12 @@ flexibility::
>>> f = ContactForm()
>>> f.as_ul()
- '<li><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required /></li>\n<li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required /></li>\n<li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required /></li>\n<li><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></li>'
+ '<li><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required></li>\n<li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required></li>\n<li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required></li>\n<li><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself"></li>'
>>> print(f.as_ul())
- <li><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required /></li>
- <li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required /></li>
- <li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required /></li>
- <li><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself" /></li>
+ <li><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" required></li>
+ <li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" required></li>
+ <li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" required></li>
+ <li><label for="id_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_cc_myself"></li>
``as_table()``
--------------
@@ -543,12 +543,12 @@ it calls its ``as_table()`` method behind the scenes::
>>> f = ContactForm()
>>> f.as_table()
- '<tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required /></td></tr>\n<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required /></td></tr>\n<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required /></td></tr>\n<tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" /></td></tr>'
+ '<tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required></td></tr>\n<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required></td></tr>\n<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required></td></tr>\n<tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself"></td></tr>'
>>> print(f)
- <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required /></td></tr>
- <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required /></td></tr>
- <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself" /></td></tr>
+ <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" required></td></tr>
+ <tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" required></td></tr>
+ <tr><th><label for="id_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_cc_myself"></td></tr>
.. _ref-forms-api-styling-form-rows:
@@ -618,20 +618,20 @@ tags nor ``id`` attributes::
>>> f = ContactForm(auto_id=False)
>>> print(f.as_table())
- <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th>Message:</th><td><input type="text" name="message" required /></td></tr>
- <tr><th>Sender:</th><td><input type="email" name="sender" required /></td></tr>
- <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself" /></td></tr>
+ <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th>Message:</th><td><input type="text" name="message" required></td></tr>
+ <tr><th>Sender:</th><td><input type="email" name="sender" required></td></tr>
+ <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself"></td></tr>
>>> print(f.as_ul())
- <li>Subject: <input type="text" name="subject" maxlength="100" required /></li>
- <li>Message: <input type="text" name="message" required /></li>
- <li>Sender: <input type="email" name="sender" required /></li>
- <li>Cc myself: <input type="checkbox" name="cc_myself" /></li>
+ <li>Subject: <input type="text" name="subject" maxlength="100" required></li>
+ <li>Message: <input type="text" name="message" required></li>
+ <li>Sender: <input type="email" name="sender" required></li>
+ <li>Cc myself: <input type="checkbox" name="cc_myself"></li>
>>> print(f.as_p())
- <p>Subject: <input type="text" name="subject" maxlength="100" required /></p>
- <p>Message: <input type="text" name="message" required /></p>
- <p>Sender: <input type="email" name="sender" required /></p>
- <p>Cc myself: <input type="checkbox" name="cc_myself" /></p>
+ <p>Subject: <input type="text" name="subject" maxlength="100" required></p>
+ <p>Message: <input type="text" name="message" required></p>
+ <p>Sender: <input type="email" name="sender" required></p>
+ <p>Cc myself: <input type="checkbox" name="cc_myself"></p>
If ``auto_id`` is set to ``True``, then the form output *will* include
``<label>`` tags and will simply use the field name as its ``id`` for each form
@@ -639,20 +639,20 @@ field::
>>> f = ContactForm(auto_id=True)
>>> print(f.as_table())
- <tr><th><label for="subject">Subject:</label></th><td><input id="subject" type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th><label for="message">Message:</label></th><td><input type="text" name="message" id="message" required /></td></tr>
- <tr><th><label for="sender">Sender:</label></th><td><input type="email" name="sender" id="sender" required /></td></tr>
- <tr><th><label for="cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="cc_myself" /></td></tr>
+ <tr><th><label for="subject">Subject:</label></th><td><input id="subject" type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th><label for="message">Message:</label></th><td><input type="text" name="message" id="message" required></td></tr>
+ <tr><th><label for="sender">Sender:</label></th><td><input type="email" name="sender" id="sender" required></td></tr>
+ <tr><th><label for="cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="cc_myself"></td></tr>
>>> print(f.as_ul())
- <li><label for="subject">Subject:</label> <input id="subject" type="text" name="subject" maxlength="100" required /></li>
- <li><label for="message">Message:</label> <input type="text" name="message" id="message" required /></li>
- <li><label for="sender">Sender:</label> <input type="email" name="sender" id="sender" required /></li>
- <li><label for="cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="cc_myself" /></li>
+ <li><label for="subject">Subject:</label> <input id="subject" type="text" name="subject" maxlength="100" required></li>
+ <li><label for="message">Message:</label> <input type="text" name="message" id="message" required></li>
+ <li><label for="sender">Sender:</label> <input type="email" name="sender" id="sender" required></li>
+ <li><label for="cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="cc_myself"></li>
>>> print(f.as_p())
- <p><label for="subject">Subject:</label> <input id="subject" type="text" name="subject" maxlength="100" required /></p>
- <p><label for="message">Message:</label> <input type="text" name="message" id="message" required /></p>
- <p><label for="sender">Sender:</label> <input type="email" name="sender" id="sender" required /></p>
- <p><label for="cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="cc_myself" /></p>
+ <p><label for="subject">Subject:</label> <input id="subject" type="text" name="subject" maxlength="100" required></p>
+ <p><label for="message">Message:</label> <input type="text" name="message" id="message" required></p>
+ <p><label for="sender">Sender:</label> <input type="email" name="sender" id="sender" required></p>
+ <p><label for="cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="cc_myself"></p>
If ``auto_id`` is set to a string containing the format character ``'%s'``,
then the form output will include ``<label>`` tags, and will generate ``id``
@@ -662,20 +662,20 @@ attributes based on the format string. For example, for a format string
>>> f = ContactForm(auto_id='id_for_%s')
>>> print(f.as_table())
- <tr><th><label for="id_for_subject">Subject:</label></th><td><input id="id_for_subject" type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th><label for="id_for_message">Message:</label></th><td><input type="text" name="message" id="id_for_message" required /></td></tr>
- <tr><th><label for="id_for_sender">Sender:</label></th><td><input type="email" name="sender" id="id_for_sender" required /></td></tr>
- <tr><th><label for="id_for_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></td></tr>
+ <tr><th><label for="id_for_subject">Subject:</label></th><td><input id="id_for_subject" type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th><label for="id_for_message">Message:</label></th><td><input type="text" name="message" id="id_for_message" required></td></tr>
+ <tr><th><label for="id_for_sender">Sender:</label></th><td><input type="email" name="sender" id="id_for_sender" required></td></tr>
+ <tr><th><label for="id_for_cc_myself">Cc myself:</label></th><td><input type="checkbox" name="cc_myself" id="id_for_cc_myself"></td></tr>
>>> print(f.as_ul())
- <li><label for="id_for_subject">Subject:</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></li>
- <li><label for="id_for_message">Message:</label> <input type="text" name="message" id="id_for_message" required /></li>
- <li><label for="id_for_sender">Sender:</label> <input type="email" name="sender" id="id_for_sender" required /></li>
- <li><label for="id_for_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></li>
+ <li><label for="id_for_subject">Subject:</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required></li>
+ <li><label for="id_for_message">Message:</label> <input type="text" name="message" id="id_for_message" required></li>
+ <li><label for="id_for_sender">Sender:</label> <input type="email" name="sender" id="id_for_sender" required></li>
+ <li><label for="id_for_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself"></li>
>>> print(f.as_p())
- <p><label for="id_for_subject">Subject:</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></p>
- <p><label for="id_for_message">Message:</label> <input type="text" name="message" id="id_for_message" required /></p>
- <p><label for="id_for_sender">Sender:</label> <input type="email" name="sender" id="id_for_sender" required /></p>
- <p><label for="id_for_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></p>
+ <p><label for="id_for_subject">Subject:</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required></p>
+ <p><label for="id_for_message">Message:</label> <input type="text" name="message" id="id_for_message" required></p>
+ <p><label for="id_for_sender">Sender:</label> <input type="email" name="sender" id="id_for_sender" required></p>
+ <p><label for="id_for_cc_myself">Cc myself:</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself"></p>
If ``auto_id`` is set to any other true value -- such as a string that doesn't
include ``%s`` -- then the library will act as if ``auto_id`` is ``True``.
@@ -692,16 +692,16 @@ It's possible to customize that character, or omit it entirely, using the
>>> f = ContactForm(auto_id='id_for_%s', label_suffix='')
>>> print(f.as_ul())
- <li><label for="id_for_subject">Subject</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></li>
- <li><label for="id_for_message">Message</label> <input type="text" name="message" id="id_for_message" required /></li>
- <li><label for="id_for_sender">Sender</label> <input type="email" name="sender" id="id_for_sender" required /></li>
- <li><label for="id_for_cc_myself">Cc myself</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></li>
+ <li><label for="id_for_subject">Subject</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required></li>
+ <li><label for="id_for_message">Message</label> <input type="text" name="message" id="id_for_message" required></li>
+ <li><label for="id_for_sender">Sender</label> <input type="email" name="sender" id="id_for_sender" required></li>
+ <li><label for="id_for_cc_myself">Cc myself</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself"></li>
>>> f = ContactForm(auto_id='id_for_%s', label_suffix=' ->')
>>> print(f.as_ul())
- <li><label for="id_for_subject">Subject -></label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></li>
- <li><label for="id_for_message">Message -></label> <input type="text" name="message" id="id_for_message" required /></li>
- <li><label for="id_for_sender">Sender -></label> <input type="email" name="sender" id="id_for_sender" required /></li>
- <li><label for="id_for_cc_myself">Cc myself -></label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></li>
+ <li><label for="id_for_subject">Subject -></label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required></li>
+ <li><label for="id_for_message">Message -></label> <input type="text" name="message" id="id_for_message" required></li>
+ <li><label for="id_for_sender">Sender -></label> <input type="email" name="sender" id="id_for_sender" required></li>
+ <li><label for="id_for_cc_myself">Cc myself -></label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself"></li>
Note that the label suffix is added only if the last character of the
label isn't a punctuation character (in English, those are ``.``, ``!``, ``?``
@@ -788,22 +788,22 @@ method you're using::
... 'cc_myself': True}
>>> f = ContactForm(data, auto_id=False)
>>> print(f.as_table())
- <tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" required /></td></tr>
- <tr><th>Message:</th><td><input type="text" name="message" value="Hi there" required /></td></tr>
- <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid email address.</li></ul><input type="email" name="sender" value="invalid email address" required /></td></tr>
- <tr><th>Cc myself:</th><td><input checked type="checkbox" name="cc_myself" /></td></tr>
+ <tr><th>Subject:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="subject" maxlength="100" required></td></tr>
+ <tr><th>Message:</th><td><input type="text" name="message" value="Hi there" required></td></tr>
+ <tr><th>Sender:</th><td><ul class="errorlist"><li>Enter a valid email address.</li></ul><input type="email" name="sender" value="invalid email address" required></td></tr>
+ <tr><th>Cc myself:</th><td><input checked type="checkbox" name="cc_myself"></td></tr>
>>> print(f.as_ul())
- <li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" required /></li>
- <li>Message: <input type="text" name="message" value="Hi there" required /></li>
- <li><ul class="errorlist"><li>Enter a valid email address.</li></ul>Sender: <input type="email" name="sender" value="invalid email address" required /></li>
- <li>Cc myself: <input checked type="checkbox" name="cc_myself" /></li>
+ <li><ul class="errorlist"><li>This field is required.</li></ul>Subject: <input type="text" name="subject" maxlength="100" required></li>
+ <li>Message: <input type="text" name="message" value="Hi there" required></li>
+ <li><ul class="errorlist"><li>Enter a valid email address.</li></ul>Sender: <input type="email" name="sender" value="invalid email address" required></li>
+ <li>Cc myself: <input checked type="checkbox" name="cc_myself"></li>
>>> print(f.as_p())
<p><ul class="errorlist"><li>This field is required.</li></ul></p>
- <p>Subject: <input type="text" name="subject" maxlength="100" required /></p>
- <p>Message: <input type="text" name="message" value="Hi there" required /></p>
+ <p>Subject: <input type="text" name="subject" maxlength="100" required></p>
+ <p>Message: <input type="text" name="message" value="Hi there" required></p>
<p><ul class="errorlist"><li>Enter a valid email address.</li></ul></p>
- <p>Sender: <input type="email" name="sender" value="invalid email address" required /></p>
- <p>Cc myself: <input checked type="checkbox" name="cc_myself" /></p>
+ <p>Sender: <input type="email" name="sender" value="invalid email address" required></p>
+ <p>Cc myself: <input checked type="checkbox" name="cc_myself"></p>
.. _ref-forms-error-list-format:
@@ -824,11 +824,11 @@ pass that in at construction time::
>>> f = ContactForm(data, auto_id=False, error_class=DivErrorList)
>>> f.as_p()
<div class="errorlist"><div class="error">This field is required.</div></div>
- <p>Subject: <input type="text" name="subject" maxlength="100" required /></p>
- <p>Message: <input type="text" name="message" value="Hi there" required /></p>
+ <p>Subject: <input type="text" name="subject" maxlength="100" required></p>
+ <p>Message: <input type="text" name="message" value="Hi there" required></p>
<div class="errorlist"><div class="error">Enter a valid email address.</div></div>
- <p>Sender: <input type="email" name="sender" value="invalid email address" required /></p>
- <p>Cc myself: <input checked type="checkbox" name="cc_myself" /></p>
+ <p>Sender: <input type="email" name="sender" value="invalid email address" required></p>
+ <p>Cc myself: <input checked type="checkbox" name="cc_myself"></p>
More granular output
====================
@@ -848,25 +848,25 @@ using the field's name as the key::
>>> form = ContactForm()
>>> print(form['subject'])
- <input id="id_subject" type="text" name="subject" maxlength="100" required />
+ <input id="id_subject" type="text" name="subject" maxlength="100" required>
To retrieve all ``BoundField`` objects, iterate the form::
>>> form = ContactForm()
>>> for boundfield in form: print(boundfield)
- <input id="id_subject" type="text" name="subject" maxlength="100" required />
- <input type="text" name="message" id="id_message" required />
- <input type="email" name="sender" id="id_sender" required />
- <input type="checkbox" name="cc_myself" id="id_cc_myself" />
+ <input id="id_subject" type="text" name="subject" maxlength="100" required>
+ <input type="text" name="message" id="id_message" required>
+ <input type="email" name="sender" id="id_sender" required>
+ <input type="checkbox" name="cc_myself" id="id_cc_myself">
The field-specific output honors the form object's ``auto_id`` setting::
>>> f = ContactForm(auto_id=False)
>>> print(f['message'])
- <input type="text" name="message" required />
+ <input type="text" name="message" required>
>>> f = ContactForm(auto_id='id_%s')
>>> print(f['message'])
- <input type="text" name="message" id="id_message" required />
+ <input type="text" name="message" id="id_message" required>
Attributes of ``BoundField``
----------------------------
@@ -897,7 +897,7 @@ Attributes of ``BoundField``
>>> data = {'subject': 'hi', 'message': '', 'sender': '', 'cc_myself': ''}
>>> f = ContactForm(data, auto_id=False)
>>> print(f['message'])
- <input type="text" name="message" required />
+ <input type="text" name="message" required>
>>> f['message'].errors
['This field is required.']
>>> print(f['message'].errors)
@@ -949,7 +949,7 @@ Attributes of ``BoundField``
.. code-block:: html
- <label for="myFIELD">...</label><input id="myFIELD" type="text" name="my_field" required />
+ <label for="myFIELD">...</label><input id="myFIELD" type="text" name="my_field" required>
.. attribute:: BoundField.is_hidden
@@ -1168,11 +1168,11 @@ fields are ordered first::
... priority = forms.CharField()
>>> f = ContactFormWithPriority(auto_id=False)
>>> print(f.as_ul())
- <li>Subject: <input type="text" name="subject" maxlength="100" required /></li>
- <li>Message: <input type="text" name="message" required /></li>
- <li>Sender: <input type="email" name="sender" required /></li>
- <li>Cc myself: <input type="checkbox" name="cc_myself" /></li>
- <li>Priority: <input type="text" name="priority" required /></li>
+ <li>Subject: <input type="text" name="subject" maxlength="100" required></li>
+ <li>Message: <input type="text" name="message" required></li>
+ <li>Sender: <input type="email" name="sender" required></li>
+ <li>Cc myself: <input type="checkbox" name="cc_myself"></li>
+ <li>Priority: <input type="text" name="priority" required></li>
It's possible to subclass multiple forms, treating forms as mixins. In this
example, ``BeatleForm`` subclasses both ``PersonForm`` and ``InstrumentForm``
@@ -1189,10 +1189,10 @@ classes::
... haircut_type = forms.CharField()
>>> b = BeatleForm(auto_id=False)
>>> print(b.as_ul())
- <li>First name: <input type="text" name="first_name" required /></li>
- <li>Last name: <input type="text" name="last_name" required /></li>
- <li>Instrument: <input type="text" name="instrument" required /></li>
- <li>Haircut type: <input type="text" name="haircut_type" required /></li>
+ <li>First name: <input type="text" name="first_name" required></li>
+ <li>Last name: <input type="text" name="last_name" required></li>
+ <li>Instrument: <input type="text" name="instrument" required></li>
+ <li>Haircut type: <input type="text" name="haircut_type" required></li>
It's possible to declaratively remove a ``Field`` inherited from a parent class
by setting the name of the field to ``None`` on the subclass. For example::
@@ -1222,11 +1222,11 @@ You can put several Django forms inside one ``<form>`` tag. To give each
>>> mother = PersonForm(prefix="mother")
>>> father = PersonForm(prefix="father")
>>> print(mother.as_ul())
- <li><label for="id_mother-first_name">First name:</label> <input type="text" name="mother-first_name" id="id_mother-first_name" required /></li>
- <li><label for="id_mother-last_name">Last name:</label> <input type="text" name="mother-last_name" id="id_mother-last_name" required /></li>
+ <li><label for="id_mother-first_name">First name:</label> <input type="text" name="mother-first_name" id="id_mother-first_name" required></li>
+ <li><label for="id_mother-last_name">Last name:</label> <input type="text" name="mother-last_name" id="id_mother-last_name" required></li>
>>> print(father.as_ul())
- <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name" required /></li>
- <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name" required /></li>
+ <li><label for="id_father-first_name">First name:</label> <input type="text" name="father-first_name" id="id_father-first_name" required></li>
+ <li><label for="id_father-last_name">Last name:</label> <input type="text" name="father-last_name" id="id_father-last_name" required></li>
The prefix can also be specified on the form class::
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 6c24c3534e..65a231d8e2 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -119,9 +119,9 @@ We've specified ``auto_id=False`` to simplify the output::
... comment = forms.CharField()
>>> f = CommentForm(auto_id=False)
>>> print(f)
- <tr><th>Your name:</th><td><input type="text" name="name" required /></td></tr>
- <tr><th>Your website:</th><td><input type="url" name="url" /></td></tr>
- <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr>
+ <tr><th>Your name:</th><td><input type="text" name="name" required></td></tr>
+ <tr><th>Your website:</th><td><input type="url" name="url"></td></tr>
+ <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr>
``label_suffix``
----------------
@@ -137,9 +137,9 @@ The ``label_suffix`` argument lets you override the form's
... captcha_answer = forms.IntegerField(label='2 + 2', label_suffix=' =')
>>> f = ContactForm(label_suffix='?')
>>> print(f.as_p())
- <p><label for="id_age">Age?</label> <input id="id_age" name="age" type="number" required /></p>
- <p><label for="id_nationality">Nationality?</label> <input id="id_nationality" name="nationality" type="text" required /></p>
- <p><label for="id_captcha_answer">2 + 2 =</label> <input id="id_captcha_answer" name="captcha_answer" type="number" required /></p>
+ <p><label for="id_age">Age?</label> <input id="id_age" name="age" type="number" required></p>
+ <p><label for="id_nationality">Nationality?</label> <input id="id_nationality" name="nationality" type="text" required></p>
+ <p><label for="id_captcha_answer">2 + 2 =</label> <input id="id_captcha_answer" name="captcha_answer" type="number" required></p>
``initial``
-----------
@@ -161,9 +161,9 @@ field is initialized to a particular value. For example::
... comment = forms.CharField()
>>> f = CommentForm(auto_id=False)
>>> print(f)
- <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required /></td></tr>
- <tr><th>Url:</th><td><input type="url" name="url" value="http://" required /></td></tr>
- <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr>
+ <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required></td></tr>
+ <tr><th>Url:</th><td><input type="url" name="url" value="http://" required></td></tr>
+ <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr>
You may be thinking, why not just pass a dictionary of the initial values as
data when displaying the form? Well, if you do that, you'll trigger validation,
@@ -176,9 +176,9 @@ and the HTML output will include any validation errors::
>>> default_data = {'name': 'Your name', 'url': 'http://'}
>>> f = CommentForm(default_data, auto_id=False)
>>> print(f)
- <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required /></td></tr>
- <tr><th>Url:</th><td><ul class="errorlist"><li>Enter a valid URL.</li></ul><input type="url" name="url" value="http://" required /></td></tr>
- <tr><th>Comment:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="comment" required /></td></tr>
+ <tr><th>Name:</th><td><input type="text" name="name" value="Your name" required></td></tr>
+ <tr><th>Url:</th><td><ul class="errorlist"><li>Enter a valid URL.</li></ul><input type="url" name="url" value="http://" required></td></tr>
+ <tr><th>Comment:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="text" name="comment" required></td></tr>
This is why ``initial`` values are only displayed for unbound forms. For bound
forms, the HTML output will use the bound data.
@@ -205,7 +205,7 @@ Instead of a constant, you can also pass any callable::
>>> class DateForm(forms.Form):
... day = forms.DateField(initial=datetime.date.today)
>>> print(DateForm())
- <tr><th>Day:</th><td><input type="text" name="day" value="12/23/2008" required /><td></tr>
+ <tr><th>Day:</th><td><input type="text" name="day" value="12/23/2008" required><td></tr>
The callable will be evaluated only when the unbound form is displayed, not when it is defined.
@@ -241,20 +241,20 @@ fields. We've specified ``auto_id=False`` to simplify the output::
... cc_myself = forms.BooleanField(required=False)
>>> f = HelpTextContactForm(auto_id=False)
>>> print(f.as_table())
- <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required /><br /><span class="helptext">100 characters max.</span></td></tr>
- <tr><th>Message:</th><td><input type="text" name="message" required /></td></tr>
- <tr><th>Sender:</th><td><input type="email" name="sender" required /><br />A valid email address, please.</td></tr>
- <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself" /></td></tr>
+ <tr><th>Subject:</th><td><input type="text" name="subject" maxlength="100" required><br><span class="helptext">100 characters max.</span></td></tr>
+ <tr><th>Message:</th><td><input type="text" name="message" required></td></tr>
+ <tr><th>Sender:</th><td><input type="email" name="sender" required><br>A valid email address, please.</td></tr>
+ <tr><th>Cc myself:</th><td><input type="checkbox" name="cc_myself"></td></tr>
>>> print(f.as_ul()))
- <li>Subject: <input type="text" name="subject" maxlength="100" required /> <span class="helptext">100 characters max.</span></li>
- <li>Message: <input type="text" name="message" required /></li>
- <li>Sender: <input type="email" name="sender" required /> A valid email address, please.</li>
- <li>Cc myself: <input type="checkbox" name="cc_myself" /></li>
+ <li>Subject: <input type="text" name="subject" maxlength="100" required> <span class="helptext">100 characters max.</span></li>
+ <li>Message: <input type="text" name="message" required></li>
+ <li>Sender: <input type="email" name="sender" required> A valid email address, please.</li>
+ <li>Cc myself: <input type="checkbox" name="cc_myself"></li>
>>> print(f.as_p())
- <p>Subject: <input type="text" name="subject" maxlength="100" required /> <span class="helptext">100 characters max.</span></p>
- <p>Message: <input type="text" name="message" required /></p>
- <p>Sender: <input type="email" name="sender" required /> A valid email address, please.</p>
- <p>Cc myself: <input type="checkbox" name="cc_myself" /></p>
+ <p>Subject: <input type="text" name="subject" maxlength="100" required> <span class="helptext">100 characters max.</span></p>
+ <p>Message: <input type="text" name="message" required></p>
+ <p>Sender: <input type="email" name="sender" required> A valid email address, please.</p>
+ <p>Cc myself: <input type="checkbox" name="cc_myself"></p>
``error_messages``
------------------
diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt
index dc6256ee06..ee913f0f72 100644
--- a/docs/ref/forms/widgets.txt
+++ b/docs/ref/forms/widgets.txt
@@ -142,9 +142,9 @@ provided for each widget will be rendered exactly the same::
>>> f = CommentForm(auto_id=False)
>>> f.as_table()
- <tr><th>Name:</th><td><input type="text" name="name" required /></td></tr>
- <tr><th>Url:</th><td><input type="url" name="url" required /></td></tr>
- <tr><th>Comment:</th><td><input type="text" name="comment" required /></td></tr>
+ <tr><th>Name:</th><td><input type="text" name="name" required></td></tr>
+ <tr><th>Url:</th><td><input type="url" name="url" required></td></tr>
+ <tr><th>Comment:</th><td><input type="text" name="comment" required></td></tr>
On a real Web page, you probably don't want every widget to look the same. You
might want a larger input element for the comment, and you might want the
@@ -161,9 +161,9 @@ Django will then include the extra attributes in the rendered output:
>>> f = CommentForm(auto_id=False)
>>> f.as_table()
- <tr><th>Name:</th><td><input type="text" name="name" class="special" required /></td></tr>
- <tr><th>Url:</th><td><input type="url" name="url" required /></td></tr>
- <tr><th>Comment:</th><td><input type="text" name="comment" size="40" required /></td></tr>
+ <tr><th>Name:</th><td><input type="text" name="name" class="special" required></td></tr>
+ <tr><th>Url:</th><td><input type="url" name="url" required></td></tr>
+ <tr><th>Comment:</th><td><input type="text" name="comment" size="40" required></td></tr>
You can also set the HTML ``id`` using :attr:`~Widget.attrs`. See
:attr:`BoundField.id_for_label` for an example.
@@ -211,18 +211,18 @@ foundation for custom widgets.
>>> from django import forms
>>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',})
>>> name.render('name', 'A name')
- '<input title="Your name" type="text" name="name" value="A name" size="10" required />'
+ '<input title="Your name" type="text" name="name" value="A name" size="10" required>'
If you assign a value of ``True`` or ``False`` to an attribute,
it will be rendered as an HTML5 boolean attribute::
>>> name = forms.TextInput(attrs={'required': True})
>>> name.render('name', 'A name')
- '<input name="name" type="text" value="A name" required />'
+ '<input name="name" type="text" value="A name" required>'
>>>
>>> name = forms.TextInput(attrs={'required': False})
>>> name.render('name', 'A name')
- '<input name="name" type="text" value="A name" />'
+ '<input name="name" type="text" value="A name">'
.. attribute:: Widget.supports_microseconds
@@ -701,16 +701,16 @@ that specifies the template used to render each choice. For example, for the
.. code-block:: html
<div class="myradio">
- <label for="id_beatles_0"><input id="id_beatles_0" name="beatles" type="radio" value="john" required /> John</label>
+ <label for="id_beatles_0"><input id="id_beatles_0" name="beatles" type="radio" value="john" required> John</label>
</div>
<div class="myradio">
- <label for="id_beatles_1"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required /> Paul</label>
+ <label for="id_beatles_1"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required> Paul</label>
</div>
<div class="myradio">
- <label for="id_beatles_2"><input id="id_beatles_2" name="beatles" type="radio" value="george" required /> George</label>
+ <label for="id_beatles_2"><input id="id_beatles_2" name="beatles" type="radio" value="george" required> George</label>
</div>
<div class="myradio">
- <label for="id_beatles_3"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required /> Ringo</label>
+ <label for="id_beatles_3"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required> Ringo</label>
</div>
That included the ``<label>`` tags. To get more granular, you can use each
@@ -732,22 +732,22 @@ that specifies the template used to render each choice. For example, for the
<label for="id_beatles_0">
John
- <span class="radio"><input id="id_beatles_0" name="beatles" type="radio" value="john" required /></span>
+ <span class="radio"><input id="id_beatles_0" name="beatles" type="radio" value="john" required></span>
</label>
<label for="id_beatles_1">
Paul
- <span class="radio"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required /></span>
+ <span class="radio"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required></span>
</label>
<label for="id_beatles_2">
George
- <span class="radio"><input id="id_beatles_2" name="beatles" type="radio" value="george" required /></span>
+ <span class="radio"><input id="id_beatles_2" name="beatles" type="radio" value="george" required></span>
</label>
<label for="id_beatles_3">
Ringo
- <span class="radio"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required /></span>
+ <span class="radio"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required></span>
</label>
If you decide not to loop over the radio buttons -- e.g., if your template
diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt
index bc870b101b..e2e8e4cec1 100644
--- a/docs/ref/request-response.txt
+++ b/docs/ref/request-response.txt
@@ -124,7 +124,7 @@ All attributes should be considered read-only, unless stated otherwise.
.. attribute:: HttpRequest.FILES
A dictionary-like object containing all uploaded files. Each key in
- ``FILES`` is the ``name`` from the ``<input type="file" name="" />``. Each
+ ``FILES`` is the ``name`` from the ``<input type="file" name="">``. Each
value in ``FILES`` is an :class:`~django.core.files.uploadedfile.UploadedFile`.
See :doc:`/topics/files` for more information.
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index ec05d16292..6f37b04320 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -1192,7 +1192,7 @@ value to a maximum value, and then applies that ratio to a constant.
For example::
<img src="bar.png" alt="Bar"
- height="10" width="{% widthratio this_value max_value max_width %}" />
+ height="10" width="{% widthratio this_value max_value max_width %}">
If ``this_value`` is 175, ``max_value`` is 200, and ``max_width`` is 100, the
image in the above example will be 88 pixels wide
@@ -1832,14 +1832,14 @@ If ``value`` is ``['a', 'b', 'c', 'd']`` or ``"abcd"``, the output will be
--------------
Replaces line breaks in plain text with appropriate HTML; a single
-newline becomes an HTML line break (``<br />``) and a new line
+newline becomes an HTML line break (``<br>``) and a new line
followed by a blank line becomes a paragraph break (``</p>``).
For example::
{{ value|linebreaks }}
-If ``value`` is ``Joel\nis a slug``, the output will be ``<p>Joel<br />is a
+If ``value`` is ``Joel\nis a slug``, the output will be ``<p>Joel<br>is a
slug</p>``.
.. templatefilter:: linebreaksbr
@@ -1848,13 +1848,13 @@ slug</p>``.
----------------
Converts all newlines in a piece of plain text to HTML line breaks
-(``<br />``).
+(``<br>``).
For example::
{{ value|linebreaksbr }}
-If ``value`` is ``Joel\nis a slug``, the output will be ``Joel<br />is a
+If ``value`` is ``Joel\nis a slug``, the output will be ``Joel<br>is a
slug``.
.. templatefilter:: linenumbers
@@ -2531,20 +2531,20 @@ app is installed, the tag will serve files using ``url()`` method of the
storage specified by :setting:`STATICFILES_STORAGE`. For example::
{% load static %}
- <img src="{% static "images/hi.jpg" %}" alt="Hi!" />
+ <img src="{% static "images/hi.jpg" %}" alt="Hi!">
It is also able to consume standard context variables, e.g. assuming a
``user_stylesheet`` variable is passed to the template::
{% load static %}
- <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen" />
+ <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen">
If you'd like to retrieve a static URL without displaying it, you can use a
slightly different call::
{% load static %}
{% static "images/hi.jpg" as myphoto %}
- <img src="{{ myphoto }}"></img>
+ <img src="{{ myphoto }}">
.. admonition:: Using Jinja2 templates?
@@ -2561,7 +2561,7 @@ over exactly where and how :setting:`STATIC_URL` is injected into the template,
you can use the :ttag:`get_static_prefix` template tag::
{% load static %}
- <img src="{% get_static_prefix %}images/hi.jpg" alt="Hi!" />
+ <img src="{% get_static_prefix %}images/hi.jpg" alt="Hi!">
There's also a second form you can use to avoid extra processing if you need
the value multiple times::
@@ -2569,8 +2569,8 @@ the value multiple times::
{% load static %}
{% get_static_prefix as STATIC_PREFIX %}
- <img src="{{ STATIC_PREFIX }}images/hi.jpg" alt="Hi!" />
- <img src="{{ STATIC_PREFIX }}images/hi2.jpg" alt="Hello!" />
+ <img src="{{ STATIC_PREFIX }}images/hi.jpg" alt="Hi!">
+ <img src="{{ STATIC_PREFIX }}images/hi2.jpg" alt="Hello!">
.. templatetag:: get_media_prefix
diff --git a/docs/ref/templates/language.txt b/docs/ref/templates/language.txt
index 806832e061..c6ce3b3dfd 100644
--- a/docs/ref/templates/language.txt
+++ b/docs/ref/templates/language.txt
@@ -291,7 +291,7 @@ It's easiest to understand template inheritance by starting with an example::
<!DOCTYPE html>
<html lang="en">
<head>
- <link rel="stylesheet" href="style.css" />
+ <link rel="stylesheet" href="style.css">
<title>{% block title %}My amazing site{% endblock %}</title>
</head>
@@ -344,7 +344,7 @@ like::
<!DOCTYPE html>
<html lang="en">
<head>
- <link rel="stylesheet" href="style.css" />
+ <link rel="stylesheet" href="style.css">
<title>My amazing blog</title>
</head>
diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt
index c0bd207445..3465f41ce5 100644
--- a/docs/releases/2.1.txt
+++ b/docs/releases/2.1.txt
@@ -255,6 +255,10 @@ Miscellaneous
:class:`~django.forms.SelectMultiple` widget now uses HTML5 boolean syntax
rather than XHTML's ``multiple="multiple"``.
+* HTML rendered by form widgets no longer includes a closing slash on void
+ elements, e.g. ``<br>``. This is incompatible within XHTML, although some
+ widgets already used aspects of HTML5 such as boolean attributes.
+
.. _deprecated-features-2.1:
Features deprecated in 2.1
diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
index 3e8a63c25f..a118e56543 100644
--- a/docs/topics/auth/default.txt
+++ b/docs/topics/auth/default.txt
@@ -1056,8 +1056,8 @@ implementation details see :ref:`using-the-views`.
</tr>
</table>
- <input type="submit" value="login" />
- <input type="hidden" name="next" value="{{ next }}" />
+ <input type="submit" value="login">
+ <input type="hidden" name="next" value="{{ next }}">
</form>
{# Assumes you setup the password_reset view in your URLconf #}
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index 08c0194e53..cb07e7ad59 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -29,8 +29,8 @@ would with a regular form::
>>> formset = ArticleFormSet()
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date"></td></tr>
As you can see it only displayed one empty form. The number of empty forms
that is displayed is controlled by the ``extra`` parameter. By default,
@@ -69,12 +69,12 @@ example::
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Django is now open source" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-12" id="id_form-0-pub_date" /></td></tr>
- <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" id="id_form-1-title" /></td></tr>
- <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" id="id_form-1-pub_date" /></td></tr>
- <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title" /></td></tr>
- <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Django is now open source" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-12" id="id_form-0-pub_date"></td></tr>
+ <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" id="id_form-1-title"></td></tr>
+ <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" id="id_form-1-pub_date"></td></tr>
+ <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title"></td></tr>
+ <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date"></td></tr>
There are now a total of three forms showing above. One for the initial data
that was passed in and two extra forms. Also note that we are passing in a
@@ -103,8 +103,8 @@ gives you the ability to limit the number of forms the formset will display::
>>> formset = ArticleFormSet()
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date"></td></tr>
If the value of ``max_num`` is greater than the number of existing items in the
initial data, up to ``extra`` additional blank forms will be added to the
@@ -406,15 +406,15 @@ Lets you create a formset with the ability to order::
... ])
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Article #1" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-10" id="id_form-0-pub_date" /></td></tr>
- <tr><th><label for="id_form-0-ORDER">Order:</label></th><td><input type="number" name="form-0-ORDER" value="1" id="id_form-0-ORDER" /></td></tr>
- <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" value="Article #2" id="id_form-1-title" /></td></tr>
- <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" value="2008-05-11" id="id_form-1-pub_date" /></td></tr>
- <tr><th><label for="id_form-1-ORDER">Order:</label></th><td><input type="number" name="form-1-ORDER" value="2" id="id_form-1-ORDER" /></td></tr>
- <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title" /></td></tr>
- <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date" /></td></tr>
- <tr><th><label for="id_form-2-ORDER">Order:</label></th><td><input type="number" name="form-2-ORDER" id="id_form-2-ORDER" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Article #1" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-10" id="id_form-0-pub_date"></td></tr>
+ <tr><th><label for="id_form-0-ORDER">Order:</label></th><td><input type="number" name="form-0-ORDER" value="1" id="id_form-0-ORDER"></td></tr>
+ <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" value="Article #2" id="id_form-1-title"></td></tr>
+ <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" value="2008-05-11" id="id_form-1-pub_date"></td></tr>
+ <tr><th><label for="id_form-1-ORDER">Order:</label></th><td><input type="number" name="form-1-ORDER" value="2" id="id_form-1-ORDER"></td></tr>
+ <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title"></td></tr>
+ <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date"></td></tr>
+ <tr><th><label for="id_form-2-ORDER">Order:</label></th><td><input type="number" name="form-2-ORDER" id="id_form-2-ORDER"></td></tr>
This adds an additional field to each form. This new field is named ``ORDER``
and is an ``forms.IntegerField``. For the forms that came from the initial
@@ -466,15 +466,15 @@ Lets you create a formset with the ability to select forms for deletion::
... ])
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Article #1" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-10" id="id_form-0-pub_date" /></td></tr>
- <tr><th><label for="id_form-0-DELETE">Delete:</label></th><td><input type="checkbox" name="form-0-DELETE" id="id_form-0-DELETE" /></td></tr>
- <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" value="Article #2" id="id_form-1-title" /></td></tr>
- <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" value="2008-05-11" id="id_form-1-pub_date" /></td></tr>
- <tr><th><label for="id_form-1-DELETE">Delete:</label></th><td><input type="checkbox" name="form-1-DELETE" id="id_form-1-DELETE" /></td></tr>
- <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title" /></td></tr>
- <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date" /></td></tr>
- <tr><th><label for="id_form-2-DELETE">Delete:</label></th><td><input type="checkbox" name="form-2-DELETE" id="id_form-2-DELETE" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" value="Article #1" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" value="2008-05-10" id="id_form-0-pub_date"></td></tr>
+ <tr><th><label for="id_form-0-DELETE">Delete:</label></th><td><input type="checkbox" name="form-0-DELETE" id="id_form-0-DELETE"></td></tr>
+ <tr><th><label for="id_form-1-title">Title:</label></th><td><input type="text" name="form-1-title" value="Article #2" id="id_form-1-title"></td></tr>
+ <tr><th><label for="id_form-1-pub_date">Pub date:</label></th><td><input type="text" name="form-1-pub_date" value="2008-05-11" id="id_form-1-pub_date"></td></tr>
+ <tr><th><label for="id_form-1-DELETE">Delete:</label></th><td><input type="checkbox" name="form-1-DELETE" id="id_form-1-DELETE"></td></tr>
+ <tr><th><label for="id_form-2-title">Title:</label></th><td><input type="text" name="form-2-title" id="id_form-2-title"></td></tr>
+ <tr><th><label for="id_form-2-pub_date">Pub date:</label></th><td><input type="text" name="form-2-pub_date" id="id_form-2-pub_date"></td></tr>
+ <tr><th><label for="id_form-2-DELETE">Delete:</label></th><td><input type="checkbox" name="form-2-DELETE" id="id_form-2-DELETE"></td></tr>
Similar to ``can_order`` this adds a new field to each form named ``DELETE``
and is a ``forms.BooleanField``. When data comes through marking any of the
@@ -540,9 +540,9 @@ default fields/attributes of the order and deletion fields::
>>> formset = ArticleFormSet()
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title" /></td></tr>
- <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date" /></td></tr>
- <tr><th><label for="id_form-0-my_field">My field:</label></th><td><input type="text" name="form-0-my_field" id="id_form-0-my_field" /></td></tr>
+ <tr><th><label for="id_form-0-title">Title:</label></th><td><input type="text" name="form-0-title" id="id_form-0-title"></td></tr>
+ <tr><th><label for="id_form-0-pub_date">Pub date:</label></th><td><input type="text" name="form-0-pub_date" id="id_form-0-pub_date"></td></tr>
+ <tr><th><label for="id_form-0-my_field">My field:</label></th><td><input type="text" name="form-0-my_field" id="id_form-0-my_field"></td></tr>
.. _custom-formset-form-kwargs:
@@ -592,14 +592,14 @@ For example, in the default case, you might see:
.. code-block:: html
<label for="id_form-0-title">Title:</label>
- <input type="text" name="form-0-title" id="id_form-0-title" />
+ <input type="text" name="form-0-title" id="id_form-0-title">
But with ``ArticleFormset(prefix='article')`` that becomes:
.. code-block:: html
<label for="id_article-0-title">Title:</label>
- <input type="text" name="article-0-title" id="id_article-0-title" />
+ <input type="text" name="article-0-title" id="id_article-0-title">
This is useful if you want to :ref:`use more than one formset in a view
<multiple-formsets-in-view>`.
diff --git a/docs/topics/forms/index.txt b/docs/topics/forms/index.txt
index 86de7d1b06..71d5a37ed9 100644
--- a/docs/topics/forms/index.txt
+++ b/docs/topics/forms/index.txt
@@ -259,7 +259,7 @@ The whole form, when rendered for the first time, will look like:
.. code-block:: html+django
<label for="your_name">Your name: </label>
- <input id="your_name" type="text" name="your_name" maxlength="100" required />
+ <input id="your_name" type="text" name="your_name" maxlength="100" required>
Note that it **does not** include the ``<form>`` tags, or a submit button.
We'll have to provide those ourselves in the template.
@@ -334,7 +334,7 @@ is:
<form action="/your-name/" method="post">
{% csrf_token %}
{{ form }}
- <input type="submit" value="Submit" />
+ <input type="submit" value="Submit">
</form>
All the form's fields and their attributes will be unpacked into HTML markup
@@ -512,13 +512,13 @@ Here's the output of ``{{ form.as_p }}`` for our ``ContactForm`` instance:
.. code-block:: html+django
<p><label for="id_subject">Subject:</label>
- <input id="id_subject" type="text" name="subject" maxlength="100" required /></p>
+ <input id="id_subject" type="text" name="subject" maxlength="100" required></p>
<p><label for="id_message">Message:</label>
<textarea name="message" id="id_message" required></textarea></p>
<p><label for="id_sender">Sender:</label>
- <input type="email" name="sender" id="id_sender" required /></p>
+ <input type="email" name="sender" id="id_sender" required></p>
<p><label for="id_cc_myself">Cc myself:</label>
- <input type="checkbox" name="cc_myself" id="id_cc_myself" /></p>
+ <input type="checkbox" name="cc_myself" id="id_cc_myself"></p>
Note that each form field has an ID attribute set to ``id_<field-name>``, which
is referenced by the accompanying label tag. This is important in ensuring that
diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt
index 28c5054bc3..6b9165339f 100644
--- a/docs/topics/forms/media.txt
+++ b/docs/topics/forms/media.txt
@@ -71,7 +71,7 @@ can be retrieved through this property::
>>> w = CalendarWidget()
>>> print(w.media)
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
@@ -114,9 +114,9 @@ requirements::
If this last CSS definition were to be rendered, it would become the following HTML::
- <link href="http://static.example.com/pretty.css" type="text/css" media="screen" rel="stylesheet" />
- <link href="http://static.example.com/lo_res.css" type="text/css" media="tv,projector" rel="stylesheet" />
- <link href="http://static.example.com/newspaper.css" type="text/css" media="print" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="screen" rel="stylesheet">
+ <link href="http://static.example.com/lo_res.css" type="text/css" media="tv,projector" rel="stylesheet">
+ <link href="http://static.example.com/newspaper.css" type="text/css" media="print" rel="stylesheet">
``js``
------
@@ -145,8 +145,8 @@ example above::
>>> w = FancyCalendarWidget()
>>> print(w.media)
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
- <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
+ <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
@@ -165,7 +165,7 @@ an ``extend=False`` declaration to the ``Media`` declaration::
>>> w = FancyCalendarWidget()
>>> print(w.media)
- <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/fancy.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
If you require even more control over inheritance, define your assets using a
@@ -228,7 +228,7 @@ was ``None``::
>>> w = CalendarWidget()
>>> print(w.media)
- <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://uploads.example.com/animations.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script>
@@ -236,7 +236,7 @@ But if :setting:`STATIC_URL` is ``'http://static.example.com/'``::
>>> w = CalendarWidget()
>>> print(w.media)
- <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script>
@@ -245,7 +245,7 @@ Or if :mod:`~django.contrib.staticfiles` is configured using the
>>> w = CalendarWidget()
>>> print(w.media)
- <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="/css/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="https://static.example.com/animations.27e20196a850.js"></script>
<script type="text/javascript" src="http://othersite.com/actions.js"></script>
@@ -268,12 +268,12 @@ operator to filter out a medium of interest. For example::
>>> w = CalendarWidget()
>>> print(w.media)
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
>>> print(w.media['css'])
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
When you use the subscript operator, the value that is returned is a
new ``Media`` object -- but one that only contains the media of interest.
@@ -300,7 +300,7 @@ specified by both::
>>> w1 = CalendarWidget()
>>> w2 = OtherWidget()
>>> print(w1.media + w2.media)
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
@@ -362,7 +362,7 @@ are part of the form::
>>> f = ContactForm()
>>> f.media
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
@@ -382,8 +382,8 @@ form::
>>> f = ContactForm()
>>> f.media
- <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet" />
- <link href="http://static.example.com/layout.css" type="text/css" media="all" rel="stylesheet" />
+ <link href="http://static.example.com/pretty.css" type="text/css" media="all" rel="stylesheet">
+ <link href="http://static.example.com/layout.css" type="text/css" media="all" rel="stylesheet">
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
<script type="text/javascript" src="http://static.example.com/actions.js"></script>
<script type="text/javascript" src="http://static.example.com/whizbang.js"></script>
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 3c49e3b8e3..553271e598 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -770,14 +770,14 @@ with the ``Author`` model. It works just like a regular formset::
>>> formset = AuthorFormSet()
>>> print(formset)
- <input type="hidden" name="form-TOTAL_FORMS" value="1" id="id_form-TOTAL_FORMS" /><input type="hidden" name="form-INITIAL_FORMS" value="0" id="id_form-INITIAL_FORMS" /><input type="hidden" name="form-MAX_NUM_FORMS" id="id_form-MAX_NUM_FORMS" />
- <tr><th><label for="id_form-0-name">Name:</label></th><td><input id="id_form-0-name" type="text" name="form-0-name" maxlength="100" /></td></tr>
+ <input type="hidden" name="form-TOTAL_FORMS" value="1" id="id_form-TOTAL_FORMS"><input type="hidden" name="form-INITIAL_FORMS" value="0" id="id_form-INITIAL_FORMS"><input type="hidden" name="form-MAX_NUM_FORMS" id="id_form-MAX_NUM_FORMS">
+ <tr><th><label for="id_form-0-name">Name:</label></th><td><input id="id_form-0-name" type="text" name="form-0-name" maxlength="100"></td></tr>
<tr><th><label for="id_form-0-title">Title:</label></th><td><select name="form-0-title" id="id_form-0-title">
<option value="" selected>---------</option>
<option value="MR">Mr.</option>
<option value="MRS">Mrs.</option>
<option value="MS">Ms.</option>
- </select><input type="hidden" name="form-0-id" id="id_form-0-id" /></td></tr>
+ </select><input type="hidden" name="form-0-id" id="id_form-0-id"></td></tr>
.. note::
@@ -959,10 +959,10 @@ so long as the total number of forms does not exceed ``max_num``::
>>> formset = AuthorFormSet(queryset=Author.objects.order_by('name'))
>>> for form in formset:
... print(form.as_table())
- <tr><th><label for="id_form-0-name">Name:</label></th><td><input id="id_form-0-name" type="text" name="form-0-name" value="Charles Baudelaire" maxlength="100" /><input type="hidden" name="form-0-id" value="1" id="id_form-0-id" /></td></tr>
- <tr><th><label for="id_form-1-name">Name:</label></th><td><input id="id_form-1-name" type="text" name="form-1-name" value="Paul Verlaine" maxlength="100" /><input type="hidden" name="form-1-id" value="3" id="id_form-1-id" /></td></tr>
- <tr><th><label for="id_form-2-name">Name:</label></th><td><input id="id_form-2-name" type="text" name="form-2-name" value="Walt Whitman" maxlength="100" /><input type="hidden" name="form-2-id" value="2" id="id_form-2-id" /></td></tr>
- <tr><th><label for="id_form-3-name">Name:</label></th><td><input id="id_form-3-name" type="text" name="form-3-name" maxlength="100" /><input type="hidden" name="form-3-id" id="id_form-3-id" /></td></tr>
+ <tr><th><label for="id_form-0-name">Name:</label></th><td><input id="id_form-0-name" type="text" name="form-0-name" value="Charles Baudelaire" maxlength="100"><input type="hidden" name="form-0-id" value="1" id="id_form-0-id"></td></tr>
+ <tr><th><label for="id_form-1-name">Name:</label></th><td><input id="id_form-1-name" type="text" name="form-1-name" value="Paul Verlaine" maxlength="100"><input type="hidden" name="form-1-id" value="3" id="id_form-1-id"></td></tr>
+ <tr><th><label for="id_form-2-name">Name:</label></th><td><input id="id_form-2-name" type="text" name="form-2-name" value="Walt Whitman" maxlength="100"><input type="hidden" name="form-2-id" value="2" id="id_form-2-id"></td></tr>
+ <tr><th><label for="id_form-3-name">Name:</label></th><td><input id="id_form-3-name" type="text" name="form-3-name" maxlength="100"><input type="hidden" name="form-3-id" id="id_form-3-id"></td></tr>
A ``max_num`` value of ``None`` (the default) puts a high limit on the number
of forms displayed (1000). In practice this is equivalent to no limit.
diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt
index 902dd7aa3a..eb97677777 100644
--- a/docs/topics/i18n/timezones.txt
+++ b/docs/topics/i18n/timezones.txt
@@ -204,7 +204,7 @@ Include a form in ``template.html`` that will ``POST`` to this view:
<option value="{{ tz }}"{% if tz == TIME_ZONE %} selected{% endif %}>{{ tz }}</option>
{% endfor %}
</select>
- <input type="submit" value="Set" />
+ <input type="submit" value="Set">
</form>
.. _time-zones-in-forms:
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index 305f3a5839..5003bfb997 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -610,7 +610,7 @@ filters::
</h1>
<p>
{% for stage in tour_stages %}
- {% cycle start end %}: {{ stage }}{% if forloop.counter|divisibleby:2 %}<br />{% else %}, {% endif %}
+ {% cycle start end %}: {{ stage }}{% if forloop.counter|divisibleby:2 %}<br>{% else %}, {% endif %}
{% endfor %}
</p>
@@ -891,9 +891,9 @@ use the ``{% get_language_info %}`` tag::
You can then access the information::
- Language code: {{ lang.code }}<br />
- Name of language: {{ lang.name_local }}<br />
- Name in English: {{ lang.name }}<br />
+ Language code: {{ lang.code }}<br>
+ Name of language: {{ lang.name_local }}<br>
+ Name in English: {{ lang.name }}<br>
Bi-directional: {{ lang.bidi }}
Name in the active language: {{ lang.name_translated }}
@@ -1788,7 +1788,7 @@ Here's example HTML template code:
{% load i18n %}
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
- <input name="next" type="hidden" value="{{ redirect_to }}" />
+ <input name="next" type="hidden" value="{{ redirect_to }}">
<select name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
@@ -1799,7 +1799,7 @@ Here's example HTML template code:
</option>
{% endfor %}
</select>
- <input type="submit" value="Go" />
+ <input type="submit" value="Go">
</form>
In this example, Django looks up the URL of the page to which the user will be
diff --git a/docs/topics/pagination.txt b/docs/topics/pagination.txt
index 81efaafd28..80a6b66fc6 100644
--- a/docs/topics/pagination.txt
+++ b/docs/topics/pagination.txt
@@ -101,7 +101,7 @@ pages along with any interesting information from the objects themselves::
{% for contact in contacts %}
{# Each "contact" is a Contact model object. #}
- {{ contact.full_name|upper }}<br />
+ {{ contact.full_name|upper }}<br>
...
{% endfor %}
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index c7ae792fb5..d3be9e2124 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1485,7 +1485,7 @@ your test suite.
self.assertHTMLEqual(
'<p>Hello <b>world!</p>',
'''<p>
- Hello <b>world! <b/>
+ Hello <b>world! </b>
</p>'''
)
self.assertHTMLEqual(