isAlphaNumericURL validator should allow dashes.
django.core.validators.isAlphaNumericURL should allow dashes. Dashes in URLs are apparently more search-engine friendly, and they don't do any harm.
Index: django/core/validators.py
===================================================================
--- django/core/validators.py (revision 1066)
+++ django/core/validators.py (working copy)
@@ -13,7 +13,7 @@
_datere = r'\d{4}-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))'
_timere = r'(?:[01]?[0-9]|2[0-3]):[0-5][0-9](?::[0-5][0-9])?'
alnum_re = re.compile(r'^\w+$')
-alnumurl_re = re.compile(r'^[\w/]+$')
+alnumurl_re = re.compile(r'^[-\w/]+$')
ansi_date_re = re.compile('^%s$' % _datere)
ansi_time_re = re.compile('^%s$' % _timere)
ansi_datetime_re = re.compile('^%s %s$' % (_datere, _timere))
@@ -58,7 +58,7 @@
def isAlphaNumericURL(field_data, all_data):
if not alnumurl_re.search(field_data):
- raise ValidationError, "This value must contain only letters, numbers, underscores or slashes."
+ raise ValidationError, "This value must contain only letters, numbers, underscores, dashes or slashes."
def isSlug(field_data, all_data):
if not slug_re.search(field_data):
A hyphen isn't an alphanumeric character, so it shouldn't be allowed in the
isAlphaNumericURL
validator. Feel free to write your own validator that takes care of hyphens.