django笔记

来源:互联网 发布:万方数据库步骤 编辑:程序博客网 时间:2024/06/06 02:21

django.contrib.humanize  提供一些个性化的模板过滤器

——————————————————————————————

用户名称后台验证,正则表达式验证:

alphanumeric = RegexValidator(r'^[0-9a-zA-Z\_]*$', 'Only alphanumeric characters and underscore are allowed.')

        try:
            alphanumeric(username)
        except:
            messages.add_message(request, messages.WARNING,_('username can only contain letters digits and underscore'))
            return HttpResponseRedirect(reverse('reg'))

0 0
原创粉丝点击