Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refs #7742 -- newforms-admin does not use oldforms `validator_list` a…

…rgument, made a custom `FlatPageForm` to check the entered URL.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8292 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 00bebaf0d1e6024c7a24a6132bf648c623290bfd 1 parent ef48a3e
@gdub gdub authored
View
15 django/contrib/flatpages/admin.py
@@ -1,9 +1,22 @@
+from django import forms
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext_lazy as _
+class FlatpageForm(forms.ModelForm):
+ url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/]+$',
+ help_text = _("Example: '/about/contact/'. Make sure to have leading"
+ " and trailing slashes."),
+ error_message = _("This value must contain only letters, numbers,"
+ " underscores, dashes or slashes."))
+
+ class Meta:
+ model = FlatPage
+
+
class FlatPageAdmin(admin.ModelAdmin):
+ form = FlatpageForm
fieldsets = (
(None, {'fields': ('url', 'title', 'content', 'sites')}),
(_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
@@ -12,4 +25,4 @@ class FlatPageAdmin(admin.ModelAdmin):
list_filter = ('sites', 'enable_comments', 'registration_required')
search_fields = ('url', 'title')
-admin.site.register(FlatPage, FlatPageAdmin)
+admin.site.register(FlatPage, FlatPageAdmin)
View
5 django/contrib/flatpages/models.py
@@ -5,8 +5,7 @@
class FlatPage(models.Model):
- url = models.CharField(_('URL'), max_length=100, validator_list=[validators.isAlphaNumericURL], db_index=True,
- help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes."))
+ url = models.CharField(_('URL'), max_length=100, db_index=True)
title = models.CharField(_('title'), max_length=200)
content = models.TextField(_('content'), blank=True)
enable_comments = models.BooleanField(_('enable comments'))
@@ -20,7 +19,7 @@ class Meta:
verbose_name = _('flat page')
verbose_name_plural = _('flat pages')
ordering = ('url',)
-
+
def __unicode__(self):
return u"%s -- %s" % (self.url, self.title)
Please sign in to comment.
Something went wrong with that request. Please try again.