diff options
| author | Edward Henderson <kutenai@me.com> | 2015-04-15 16:28:49 -0600 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-07-17 13:48:58 -0400 |
| commit | f8cc464452f495fce2a3d6f7494396c8f798a1e6 (patch) | |
| tree | 61049a8351e327b59c98341f98dacda0e8186be2 /docs/ref | |
| parent | adffff79a36f7de30f438915c492e475e17025f6 (diff) | |
Fixed #16501 -- Added an allow_unicode parameter to SlugField.
Thanks Flavio Curella and Berker Peksag for the initial patch.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/forms/fields.txt | 9 | ||||
| -rw-r--r-- | docs/ref/models/fields.txt | 7 | ||||
| -rw-r--r-- | docs/ref/utils.txt | 19 | ||||
| -rw-r--r-- | docs/ref/validators.txt | 10 |
4 files changed, 41 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`` ------------------------- |
