mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.7.x] Fixed #23558 -- documented slugify limitations
Backport of 03467368db from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							cb952099f4
						
					
				
				
					commit
					d9bb7128fe
				
			| @@ -232,9 +232,9 @@ def make_list(value): | ||||
| @stringfilter | ||||
| def slugify(value): | ||||
|     """ | ||||
|     Converts to lowercase, removes non-word characters (alphanumerics and | ||||
|     underscores) and converts spaces to hyphens. Also strips leading and | ||||
|     trailing whitespace. | ||||
|     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. | ||||
|     """ | ||||
|     return _slugify(value) | ||||
|  | ||||
|   | ||||
| @@ -435,9 +435,9 @@ unescape_string_literal = allow_lazy(unescape_string_literal) | ||||
|  | ||||
| def slugify(value): | ||||
|     """ | ||||
|     Converts to lowercase, removes non-word characters (alphanumerics and | ||||
|     underscores) and converts spaces to hyphens. Also strips leading and | ||||
|     trailing whitespace. | ||||
|     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. | ||||
|     """ | ||||
|     value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') | ||||
|     value = re.sub('[^\w\s-]', '', value).strip().lower() | ||||
|   | ||||
| @@ -2036,9 +2036,9 @@ If ``some_list`` is ``['a', 'b', 'c']``, the output will be ``['a', 'b']``. | ||||
| slugify | ||||
| ^^^^^^^ | ||||
|  | ||||
| Converts to lowercase, removes non-word characters (alphanumerics and | ||||
| underscores) and converts spaces to hyphens. Also strips leading and trailing | ||||
| whitespace. | ||||
| 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. | ||||
|  | ||||
| For example:: | ||||
|  | ||||
|   | ||||
| @@ -817,9 +817,9 @@ appropriate entities. | ||||
|  | ||||
| .. function:: slugify | ||||
|  | ||||
|     Converts to lowercase, removes non-word characters (alphanumerics and | ||||
|     underscores) and converts spaces to hyphens. Also strips leading and | ||||
|     trailing whitespace. | ||||
|     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. | ||||
|  | ||||
|     For example:: | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user