尝试将表单数据保存到数据库时出现 AttributeError 消息

时间:2021-03-24 04:43:20

标签: python forms django-views

from django.shortcuts import render
    from .forms import RegisterForm

def register(feauest):
  if request.method=='POST':
     form=RegisterForm(request.POST)
     if form.is_valid():
         name=form.cleaned_data['username']
         password=form.cleaned_data['password']
         email=form.cleaned_data['email']
         gender=form.cleaned_data['gender']

         form.save()

form=RegisterForm()
return render(request, 'form.html', {'form': form})'

当我运行它时,我得到一个 AttributeError: 'RegisterForm' object has no attribute 'save'

请谁能帮我修复它。

0 个答案:

没有答案