diff options
| author | Claude Paroz <claude@2xlibre.net> | 2014-03-22 21:30:49 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2014-03-22 21:32:20 +0100 |
| commit | 3a97f992fbfbcf8b0480875b257e5d541a4b8315 (patch) | |
| tree | c5ac40df266f098c5b7b1378864685869fe2a324 /docs/ref | |
| parent | 232181d1c5307d9af5fc292682661e91439a9289 (diff) | |
Fixed #22313 -- Removed 'u' prefixes from documentation
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/syndication.txt | 18 | ||||
| -rw-r--r-- | docs/ref/forms/api.txt | 20 | ||||
| -rw-r--r-- | docs/ref/forms/fields.txt | 40 | ||||
| -rw-r--r-- | docs/ref/forms/validation.txt | 2 | ||||
| -rw-r--r-- | docs/ref/forms/widgets.txt | 4 | ||||
| -rw-r--r-- | docs/ref/models/instances.txt | 12 | ||||
| -rw-r--r-- | docs/ref/models/querysets.txt | 4 | ||||
| -rw-r--r-- | docs/ref/request-response.txt | 16 | ||||
| -rw-r--r-- | docs/ref/templates/builtins.txt | 4 | ||||
| -rw-r--r-- | docs/ref/unicode.txt | 8 | ||||
| -rw-r--r-- | docs/ref/urlresolvers.txt | 2 | ||||
| -rw-r--r-- | docs/ref/utils.txt | 14 | ||||
| -rw-r--r-- | docs/ref/validators.txt | 2 |
13 files changed, 73 insertions, 73 deletions
diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt index 65b4582deb..277e51c71e 100644 --- a/docs/ref/contrib/syndication.txt +++ b/docs/ref/contrib/syndication.txt @@ -971,16 +971,16 @@ For example, to create an Atom 1.0 feed and print it to standard output:: >>> from django.utils import feedgenerator >>> from datetime import datetime >>> f = feedgenerator.Atom1Feed( - ... title=u"My Weblog", - ... link=u"http://www.example.com/", - ... description=u"In which I write about what I ate today.", - ... language=u"en", - ... author_name=u"Myself", - ... feed_url=u"http://example.com/atom.xml") - >>> f.add_item(title=u"Hot dog today", - ... link=u"http://www.example.com/entries/1/", + ... title="My Weblog", + ... link="http://www.example.com/", + ... description="In which I write about what I ate today.", + ... language="en", + ... author_name="Myself", + ... feed_url="http://example.com/atom.xml") + >>> f.add_item(title="Hot dog today", + ... link="http://www.example.com/entries/1/", ... pubdate=datetime.now(), - ... description=u"<p>Today I had a Vienna Beef hot dog. It was pink, plump and perfect.</p>") + ... description="<p>Today I had a Vienna Beef hot dog. It was pink, plump and perfect.</p>") >>> print(f.writeString('UTF-8')) <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> diff --git a/docs/ref/forms/api.txt b/docs/ref/forms/api.txt index 33fcf85511..c4d0b18b0f 100644 --- a/docs/ref/forms/api.txt +++ b/docs/ref/forms/api.txt @@ -103,7 +103,7 @@ Access the :attr:`~Form.errors` attribute to get a dictionary of error messages:: >>> f.errors - {'sender': [u'Enter a valid email address.'], 'subject': [u'This field is required.']} + {'sender': ['Enter a valid email address.'], 'subject': ['This field is required.']} In this dictionary, the keys are the field names, and the values are lists of Unicode strings representing the error messages. The error messages are stored @@ -291,7 +291,7 @@ it, you can access the clean data via its ``cleaned_data`` attribute:: >>> f.is_valid() True >>> f.cleaned_data - {'cc_myself': True, 'message': u'Hi there', 'sender': u'foo@example.com', 'subject': u'hello'} + {'cc_myself': True, 'message': 'Hi there', 'sender': 'foo@example.com', 'subject': 'hello'} Note that any text-based field -- such as ``CharField`` or ``EmailField`` -- always cleans the input into a Unicode string. We'll cover the encoding @@ -308,7 +308,7 @@ only the valid fields:: >>> f.is_valid() False >>> f.cleaned_data - {'cc_myself': True, 'message': u'Hi there'} + {'cc_myself': True, 'message': 'Hi there'} ``cleaned_data`` will always *only* contain a key for fields defined in the ``Form``, even if you pass extra data when you define the ``Form``. In this @@ -326,7 +326,7 @@ but ``cleaned_data`` contains only the form's fields:: >>> f.is_valid() True >>> f.cleaned_data # Doesn't contain extra_field_1, etc. - {'cc_myself': True, 'message': u'Hi there', 'sender': u'foo@example.com', 'subject': u'hello'} + {'cc_myself': True, 'message': 'Hi there', 'sender': 'foo@example.com', 'subject': 'hello'} When the ``Form`` is valid, ``cleaned_data`` will include a key and value for *all* its fields, even if the data didn't include a value for some optional @@ -338,12 +338,12 @@ fields. In this example, the data dictionary doesn't include a value for the ... first_name = CharField() ... last_name = CharField() ... nick_name = CharField(required=False) - >>> data = {'first_name': u'John', 'last_name': u'Lennon'} + >>> data = {'first_name': 'John', 'last_name': 'Lennon'} >>> f = OptionalPersonForm(data) >>> f.is_valid() True >>> f.cleaned_data - {'nick_name': u'', 'first_name': u'John', 'last_name': u'Lennon'} + {'nick_name': '', 'first_name': 'John', 'last_name': 'Lennon'} In this above example, the ``cleaned_data`` value for ``nick_name`` is set to an empty string, because ``nick_name`` is ``CharField``, and ``CharField``\s treat @@ -428,7 +428,7 @@ containing one field:: >>> f = ContactForm() >>> f.as_p() - u'<p><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></p>\n<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p>\n<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></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" /></p>\n<p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p>\n<p><label for="id_sender">Sender:</label> <input type="text" name="sender" id="id_sender" /></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" /></p> <p><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></p> @@ -447,7 +447,7 @@ flexibility:: >>> f = ContactForm() >>> f.as_ul() - u'<li><label for="id_subject">Subject:</label> <input id="id_subject" type="text" name="subject" maxlength="100" /></li>\n<li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></li>\n<li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" /></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" /></li>\n<li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></li>\n<li><label for="id_sender">Sender:</label> <input type="email" name="sender" id="id_sender" /></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" /></li> <li><label for="id_message">Message:</label> <input type="text" name="message" id="id_message" /></li> @@ -465,7 +465,7 @@ it calls its ``as_table()`` method behind the scenes:: >>> f = ContactForm() >>> f.as_table() - u'<tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" /></td></tr>\n<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" /></td></tr>\n<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" /></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" /></td></tr>\n<tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" /></td></tr>\n<tr><th><label for="id_sender">Sender:</label></th><td><input type="email" name="sender" id="id_sender" /></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.as_table()) <tr><th><label for="id_subject">Subject:</label></th><td><input id="id_subject" type="text" name="subject" maxlength="100" /></td></tr> <tr><th><label for="id_message">Message:</label></th><td><input type="text" name="message" id="id_message" /></td></tr> @@ -752,7 +752,7 @@ when printed:: >>> print(f['message']) <input type="text" name="message" /> >>> f['message'].errors - [u'This field is required.'] + ['This field is required.'] >>> print(f['message'].errors) <ul class="errorlist"><li>This field is required.</li></ul> >>> f['subject'].errors diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 5363284b39..4b092f4b4f 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -24,11 +24,11 @@ exception or returns the clean value:: >>> from django import forms >>> f = forms.EmailField() >>> f.clean('foo@example.com') - u'foo@example.com' + 'foo@example.com' >>> f.clean('invalid email address') Traceback (most recent call last): ... - ValidationError: [u'Enter a valid email address.'] + ValidationError: ['Enter a valid email address.'] .. _core-field-arguments: @@ -51,40 +51,40 @@ an empty value -- either ``None`` or the empty string (``""``) -- then >>> from django import forms >>> f = forms.CharField() >>> f.clean('foo') - u'foo' + 'foo' >>> f.clean('') Traceback (most recent call last): ... - ValidationError: [u'This field is required.'] + ValidationError: ['This field is required.'] >>> f.clean(None) Traceback (most recent call last): ... - ValidationError: [u'This field is required.'] + ValidationError: ['This field is required.'] >>> f.clean(' ') - u' ' + ' ' >>> f.clean(0) - u'0' + '0' >>> f.clean(True) - u'True' + 'True' >>> f.clean(False) - u'False' + 'False' To specify that a field is *not* required, pass ``required=False`` to the ``Field`` constructor:: >>> f = forms.CharField(required=False) >>> f.clean('foo') - u'foo' + 'foo' >>> f.clean('') - u'' + '' >>> f.clean(None) - u'' + '' >>> f.clean(0) - u'0' + '0' >>> f.clean(True) - u'True' + 'True' >>> f.clean(False) - u'False' + 'False' If a ``Field`` has ``required=False`` and you pass ``clean()`` an empty value, then ``clean()`` will return a *normalized* empty value rather than raising @@ -175,7 +175,7 @@ validation if a particular field's value is not given. ``initial`` values are False # The form does *not* fall back to using the initial values. >>> f.errors - {'url': [u'This field is required.'], 'name': [u'This field is required.']} + {'url': ['This field is required.'], 'name': ['This field is required.']} Instead of a constant, you can also pass any callable:: @@ -245,7 +245,7 @@ want to override. For example, here is the default error message:: >>> generic.clean('') Traceback (most recent call last): ... - ValidationError: [u'This field is required.'] + ValidationError: ['This field is required.'] And here is a custom error message:: @@ -253,7 +253,7 @@ And here is a custom error message:: >>> name.clean('') Traceback (most recent call last): ... - ValidationError: [u'Please enter your name'] + ValidationError: ['Please enter your name'] In the `built-in Field classes`_ section below, each ``Field`` defines the error message keys it uses. @@ -867,11 +867,11 @@ Slightly complex built-in ``Field`` classes >>> from django.forms import ComboField >>> f = ComboField(fields=[CharField(max_length=20), EmailField()]) >>> f.clean('test@example.com') - u'test@example.com' + 'test@example.com' >>> f.clean('longemailaddress@example.com') Traceback (most recent call last): ... - ValidationError: [u'Ensure this value has at most 20 characters (it has 28).'] + ValidationError: ['Ensure this value has at most 20 characters (it has 28).'] ``MultiValueField`` ~~~~~~~~~~~~~~~~~~~ diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt index 78a022d436..6ee9bb17a5 100644 --- a/docs/ref/forms/validation.txt +++ b/docs/ref/forms/validation.txt @@ -408,7 +408,7 @@ sample) looks like this:: subject = cleaned_data.get("subject") if cc_myself and subject and "help" not in subject: - msg = u"Must put 'help' in subject when cc'ing yourself." + msg = "Must put 'help' in subject when cc'ing yourself." self.add_error('cc_myself', msg) self.add_error('subject', msg) diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index f6b8fd6c47..7ed30e030a 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -203,7 +203,7 @@ foundation for custom widgets. >>> from django import forms >>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',}) >>> name.render('name', 'A name') - u'<input title="Your name" type="text" name="name" value="A name" size="10" />' + '<input title="Your name" type="text" name="name" value="A name" size="10" />' .. versionchanged:: 1.8 @@ -342,7 +342,7 @@ foundation for custom widgets. return [None, None, None] def format_output(self, rendered_widgets): - return u''.join(rendered_widgets) + return ''.join(rendered_widgets) def value_from_datadict(self, data, files, name): datelist = [ diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 21bcba4636..ba84f2de81 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -449,7 +449,7 @@ For example:: last_name = models.CharField(max_length=50) def __unicode__(self): - return u'%s %s' % (self.first_name, self.last_name) + return '%s %s' % (self.first_name, self.last_name) If you define a ``__unicode__()`` method on your model and not a :meth:`~Model.__str__()` method, Django will automatically provide you with a @@ -724,9 +724,9 @@ For example:: class Person(models.Model): SHIRT_SIZES = ( - (u'S', u'Small'), - (u'M', u'Medium'), - (u'L', u'Large'), + ('S', 'Small'), + ('M', 'Medium'), + ('L', 'Large'), ) name = models.CharField(max_length=60) shirt_size = models.CharField(max_length=2, choices=SHIRT_SIZES) @@ -736,9 +736,9 @@ For example:: >>> p = Person(name="Fred Flintstone", shirt_size="L") >>> p.save() >>> p.shirt_size - u'L' + 'L' >>> p.get_shirt_size_display() - u'Large' + 'Large' .. method:: Model.get_next_by_FOO(\**kwargs) .. method:: Model.get_previous_by_FOO(\**kwargs) diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index f10f66425a..ac552bf0c7 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -484,7 +484,7 @@ A few subtleties that are worth mentioning: For example:: >>> Entry.objects.values() - [{'blog_id': 1, 'headline': u'First Entry', ...}, ...] + [{'blog_id': 1, 'headline': 'First Entry', ...}, ...] >>> Entry.objects.values('blog') [{'blog': 1}, ...] @@ -554,7 +554,7 @@ respective field passed into the ``values_list()`` call — so the first item is the first field, etc. For example:: >>> Entry.objects.values_list('id', 'headline') - [(1, u'First entry'), ...] + [(1, 'First entry'), ...] If you only pass in a single field, you can also pass in the ``flat`` parameter. If ``True``, this will mean the returned results are single values, diff --git a/docs/ref/request-response.txt b/docs/ref/request-response.txt index f4a8a17ed1..389ecec732 100644 --- a/docs/ref/request-response.txt +++ b/docs/ref/request-response.txt @@ -425,9 +425,9 @@ a subclass of dictionary. Exceptions are outlined here: >>> q = q.copy() # to make it mutable >>> q.update({'a': '2'}) >>> q.getlist('a') - [u'1', u'2'] + ['1', '2'] >>> q['a'] # returns the last - [u'2'] + ['2'] .. method:: QueryDict.items() @@ -436,7 +436,7 @@ a subclass of dictionary. Exceptions are outlined here: >>> q = QueryDict('a=1&a=2&a=3') >>> q.items() - [(u'a', u'3')] + [('a', '3')] .. method:: QueryDict.iteritems() @@ -456,7 +456,7 @@ a subclass of dictionary. Exceptions are outlined here: >>> q = QueryDict('a=1&a=2&a=3') >>> q.values() - [u'3'] + ['3'] .. method:: QueryDict.itervalues() @@ -497,7 +497,7 @@ In addition, ``QueryDict`` has the following methods: >>> q = QueryDict('a=1&a=2&a=3') >>> q.lists() - [(u'a', [u'1', u'2', u'3'])] + [('a', ['1', '2', '3'])] .. method:: QueryDict.pop(key) @@ -506,7 +506,7 @@ In addition, ``QueryDict`` has the following methods: >>> q = QueryDict('a=1&a=2&a=3', mutable=True) >>> q.pop('a') - [u'1', u'2', u'3'] + ['1', '2', '3'] .. method:: QueryDict.popitem() @@ -517,7 +517,7 @@ In addition, ``QueryDict`` has the following methods: >>> q = QueryDict('a=1&a=2&a=3', mutable=True) >>> q.popitem() - (u'a', [u'1', u'2', u'3']) + ('a', ['1', '2', '3']) .. method:: QueryDict.dict() @@ -527,7 +527,7 @@ In addition, ``QueryDict`` has the following methods: >>> q = QueryDict('a=1&a=3&a=5') >>> q.dict() - {u'a': u'5'} + {'a': '5'} .. method:: QueryDict.urlencode([safe]) diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index b5734f234f..c37bd8318a 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -1794,8 +1794,8 @@ For example:: {{ value|make_list }} If ``value`` is the string ``"Joel"``, the output would be the list -``[u'J', u'o', u'e', u'l']``. If ``value`` is ``123``, the output will be the -list ``[u'1', u'2', u'3']``. +``['J', 'o', 'e', 'l']``. If ``value`` is ``123``, the output will be the +list ``['1', '2', '3']``. .. templatefilter:: phone2numeric diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt index 306a2dfb48..d8581e801c 100644 --- a/docs/ref/unicode.txt +++ b/docs/ref/unicode.txt @@ -201,9 +201,9 @@ like that. An example might clarify things here:: - >>> urlquote(u'Paris & Orléans') - u'Paris%20%26%20Orl%C3%A9ans' - >>> iri_to_uri(u'/favorites/François/%s' % urlquote('Paris & Orléans')) + >>> urlquote('Paris & Orléans') + 'Paris%20%26%20Orl%C3%A9ans' + >>> iri_to_uri('/favorites/François/%s' % urlquote('Paris & Orléans')) '/favorites/Fran%C3%A7ois/Paris%20%26%20Orl%C3%A9ans' If you look carefully, you can see that the portion that was generated by @@ -279,7 +279,7 @@ above_. For example:: from django.utils.http import urlquote def get_absolute_url(self): - url = u'/person/%s/?x=0&y=0' % urlquote(self.location) + url = '/person/%s/?x=0&y=0' % urlquote(self.location) return iri_to_uri(url) This function returns a correctly encoded URL even if ``self.location`` is diff --git a/docs/ref/urlresolvers.txt b/docs/ref/urlresolvers.txt index 3467319d2f..2c57a5e1cd 100644 --- a/docs/ref/urlresolvers.txt +++ b/docs/ref/urlresolvers.txt @@ -64,7 +64,7 @@ You can use ``kwargs`` instead of ``args``. For example:: The string returned by ``reverse()`` is already :ref:`urlquoted <uri-and-iri-handling>`. For example:: - >>> reverse('cities', args=[u'Orléans']) + >>> reverse('cities', args=['Orléans']) '.../Orl%C3%A9ans/' Applying further encoding (such as :meth:`~django.utils.http.urlquote` or diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 5515c01a20..416a1edd2c 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -295,14 +295,14 @@ Sample usage:: >>> from django.utils import feedgenerator >>> feed = feedgenerator.Rss201rev2Feed( - ... title=u"Poynter E-Media Tidbits", - ... link=u"http://www.poynter.org/column.asp?id=31", - ... description=u"A group Weblog by the sharpest minds in online media/journalism/publishing.", - ... language=u"en", + ... title="Poynter E-Media Tidbits", + ... link="http://www.poynter.org/column.asp?id=31", + ... description="A group Weblog by the sharpest minds in online media/journalism/publishing.", + ... language="en", ... ) >>> feed.add_item( ... title="Hello", - ... link=u"http://www.holovaty.com/test/", + ... link="http://www.holovaty.com/test/", ... description="Testing." ... ) >>> with open('test.rss', 'w') as fp: @@ -559,7 +559,7 @@ escaping HTML. .. code-block:: python - mark_safe(u"%s <b>%s</b> %s" % (some_html, + mark_safe("%s <b>%s</b> %s" % (some_html, escape(some_text), escape(some_other_text), )) @@ -568,7 +568,7 @@ escaping HTML. .. code-block:: python - format_html(u"{0} <b>{1}</b> {2}", + format_html("{0} <b>{1}</b> {2}", mark_safe(some_html), some_text, some_other_text) This has the advantage that you don't need to apply :func:`escape` to each diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index eb2e1d0d02..364606666b 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -19,7 +19,7 @@ For example, here's a validator that only allows even numbers:: def validate_even(value): if value % 2 != 0: - raise ValidationError(u'%s is not an even number' % value) + raise ValidationError('%s is not an even number' % value) You can add this to a model field via the field's :attr:`~django.db.models.Field.validators` argument:: |
