summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorEdward Henderson <kutenai@me.com>2015-04-15 16:28:49 -0600
committerTim Graham <timograham@gmail.com>2015-07-17 13:48:58 -0400
commitf8cc464452f495fce2a3d6f7494396c8f798a1e6 (patch)
tree61049a8351e327b59c98341f98dacda0e8186be2 /docs
parentadffff79a36f7de30f438915c492e475e17025f6 (diff)
Fixed #16501 -- Added an allow_unicode parameter to SlugField.
Thanks Flavio Curella and Berker Peksag for the initial patch.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/fields.txt9
-rw-r--r--docs/ref/models/fields.txt7
-rw-r--r--docs/ref/utils.txt19
-rw-r--r--docs/ref/validators.txt10
-rw-r--r--docs/releases/1.9.txt11
5 files changed, 52 insertions, 4 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 776ef873ad..88c35829c0 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -875,6 +875,15 @@ For each field, we describe the default widget used if you don't specify
This field is intended for use in representing a model
:class:`~django.db.models.SlugField` in forms.
+ Takes an optional parameter:
+
+ .. attribute:: allow_unicode
+
+ .. versionadded:: 1.9
+
+ A boolean instructing the field to accept Unicode letters in addition
+ to ASCII letters. Defaults to ``False``.
+
``TimeField``
~~~~~~~~~~~~~
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 19b73aaada..6d3176512c 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -1012,6 +1012,13 @@ It is often useful to automatically prepopulate a SlugField based on the value
of some other value. You can do this automatically in the admin using
:attr:`~django.contrib.admin.ModelAdmin.prepopulated_fields`.
+.. attribute:: SlugField.allow_unicode
+
+ .. versionadded:: 1.9
+
+ If ``True``, the field accepts Unicode letters in addition to ASCII
+ letters. Defaults to ``False``.
+
``SmallIntegerField``
---------------------
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 7912edd5ce..d053dee8df 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -836,11 +836,11 @@ appropriate entities.
.. module:: django.utils.text
:synopsis: Text manipulation.
-.. function:: slugify
+.. function:: slugify(allow_unicode=False)
- Converts to ASCII. Converts spaces to hyphens. Removes characters that
- aren't alphanumerics, underscores, or hyphens. Converts to lowercase. Also
- strips leading and trailing whitespace.
+ Converts to ASCII if ``allow_unicode`` is ``False`` (default). Converts spaces to
+ hyphens. Removes characters that aren't alphanumerics, underscores, or
+ hyphens. Converts to lowercase. Also strips leading and trailing whitespace.
For example::
@@ -849,6 +849,17 @@ appropriate entities.
If ``value`` is ``"Joel is a slug"``, the output will be
``"joel-is-a-slug"``.
+ You can set the ``allow_unicode`` parameter to ``True``, if you want to
+ allow Unicode characters::
+
+ slugify(value, allow_unicode=True)
+
+ If ``value`` is ``"你好 World"``, the output will be ``"你好-world"``.
+
+ .. versionchanged:: 1.9
+
+ The ``allow_unicode`` parameter was added.
+
.. _time-zone-selection-functions:
``django.utils.timezone``
diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt
index c297209b03..ebcbd081eb 100644
--- a/docs/ref/validators.txt
+++ b/docs/ref/validators.txt
@@ -183,6 +183,16 @@ to, or in lieu of custom ``field.clean()`` methods.
A :class:`RegexValidator` instance that ensures a value consists of only
letters, numbers, underscores or hyphens.
+``validate_unicode_slug``
+-------------------------
+
+.. data:: validate_unicode_slug
+
+ .. versionadded:: 1.9
+
+ A :class:`RegexValidator` instance that ensures a value consists of only
+ Unicode letters, numbers, underscores, or hyphens.
+
``validate_ipv4_address``
-------------------------
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 6dc0e8473f..162430e502 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -308,6 +308,10 @@ Forms
* You can now :ref:`specify keyword arguments <custom-formset-form-kwargs>`
that you want to pass to the constructor of forms in a formset.
+* :class:`~django.forms.SlugField` now accepts an
+ :attr:`~django.forms.SlugField.allow_unicode` argument to allow Unicode
+ characters in slugs.
+
* :class:`~django.forms.CharField` now accepts a
:attr:`~django.forms.CharField.strip` argument to strip input data of leading
and trailing whitespace. As this defaults to ``True`` this is different
@@ -426,6 +430,10 @@ Models
* Added the :class:`~django.db.models.functions.Now` database function, which
returns the current date and time.
+* :class:`~django.db.models.SlugField` now accepts an
+ :attr:`~django.db.models.SlugField.allow_unicode` argument to allow Unicode
+ characters in slugs.
+
CSRF
^^^^
@@ -536,6 +544,9 @@ Validators
* :class:`~django.core.validators.EmailValidator` now limits the length of
domain name labels to 63 characters per :rfc:`1034`.
+* Added :func:`~django.core.validators.validate_unicode_slug` to validate slugs
+ that may contain Unicode characters.
+
Backwards incompatible changes in 1.9
=====================================