我正在尝试将Django表单中的数据插入到Postgres表中。没有错误,但它没有插入,并且重定向到感谢页面正在发生,所以它似乎正在通过该方法没有问题。
def email(request):
if request.method == 'GET':
form = ContactForm()
else:
form = ContactForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
city = form.cleaned_data['city']
m = MyUser(email=email, city=city, registration_date=datetime.now())
m.save()
return redirect('thanks')
return render(request, "email.html", {'form': form})