7.4.FormModel
FormModel
organization/form.py
import re
from django import forms
from operation.models import UserAsk
class UserAskForm(forms.ModelForm):
class Meta:
model = UserAsk
fields = ['name', 'mobile', 'course_name']
def clean_mobile(self):
"""
验证手机号码合法性
:return:
"""
mobile = self.cleaned_data['mobile']
regex_mobile = '^1(3[0-9]|4[5,7]|5[0,1,2,3,5,6,7,8,9]|6[2,5,6,7]|7[0,1,7,8]|8[0-9]|9[1,8,9])\d{8}$'
p = re.compile(regex_mobile)
if p.match(mobile):
return mobile
else:
raise forms.ValidationError('手机号码非法', code='mobile_invalid')返回json对象
organization/views.py
templates/org-list.html
url include
hello_django/urls.py
organization/urls.py
templates/index.html
视频播放 video js
获取请求url实现菜单选中
Last updated
Was this helpful?