from django import forms from app0 import models as mao class UserInfoModelForm(forms.ModelForm): class Meta: model = mao.UserInfo fields = 'all'
def modelForm(request): if request.method == 'GET': obj = UserInfoModelForm() return render(request,'modelfile.html',{'obj':obj}) if request.method == 'POST': obj = UserInfoModelForm(request.POST)
if obj.is_valid(): obj.save()return render(request,'modelfile.html',{'obj':obj})
class UserInfo(models.Model): user = models.CharField(max_length=32,verbose_name='用户名') pwd = models.CharField(max_length=32,verbose_name='密码')