mirror of https://github.com/django/django.git
Refs #7742 -- newforms-admin does not use oldforms `validator_list` argument, 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
This commit is contained in:
parent
ef48a3e69c
commit
00bebaf0d1
|
@ -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')}),
|
||||
|
|
|
@ -5,8 +5,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||
|
||||
|
||||
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'))
|
||||
|
|
Loading…
Reference in New Issue