diff --git a/core/models.py b/core/models.py index 1d2e5879..b5480cc4 100644 --- a/core/models.py +++ b/core/models.py @@ -732,7 +732,15 @@ class Page(models.Model): Be careful with the _full_name attribute: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when playing with a Page object, use get_full_name() instead! """ - name = models.CharField(_('page name'), max_length=30, blank=False) + name = models.CharField(_('page unix name'), max_length=30, + validators=[ + validators.RegexValidator( + r'^[\w.+-]+$', + _('Enter a valid page name. This value may contain only ' + 'letters, numbers ' 'and ./+/-/_ characters.') + ), + ], + blank=False) parent = models.ForeignKey('self', related_name="children", verbose_name=_("parent"), null=True, blank=True, on_delete=models.SET_NULL) # Attention: this field may not be valid until you call save(). It's made for fast query, but don't rely on it when # playing with a Page object, use get_full_name() instead! diff --git a/core/templates/core/page_list.jinja b/core/templates/core/page_list.jinja index 0e382ecb..39e9b69f 100644 --- a/core/templates/core/page_list.jinja +++ b/core/templates/core/page_list.jinja @@ -9,7 +9,7 @@