from django.shortcuts import render, redirect
from django.http import HttpResponse
from .models import Tutorial
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import login, logout, authenticate
from django.contrib.auth.models import User
def register (request):
form = UserCreationForm(request.POST)
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
user = form.save()
login(request, user)
return redirect("main:homepage")
else:
for msg in form.error_messages():
print(form.error_messages[msg])
return render(request,
'main/register.html',
context={'form':form})
但我仍然收到此错误“‘dict’对象不可调用请求方法:POST 请求 URL: http: //127.0.0.1 :8000/register/ Django 版本:3.0.7 异常类型:TypeError 异常值:‘dict’对象不可调用"
慕尼黑5688855
相关分类