I have an issue with autenticate () method , please help me. it return to me '' the view didn't return an httpresponse . It returned none instead.
def registrazione (request):
if request.method == 'POST':
form = FormSito(request.POST)
if form.is_valid():
username = form.cleaned_data ["username"]
password = form.cleaned_data ["password"]
User.objects.create_user (
username = 'username',
password = 'password'
)
user = authenticate (request,User)
else:
form = FormSito()
context = { form : 'form' }
return render (request,"registration/form/registrazione.html", context)
The error clearly says what is happening here. You simply don't return anything when the form.is_valid() is true.
def registrazione (request):
if request.method == 'POST':
form = FormSito(request.POST)
if form.is_valid():
username = form.cleaned_data ["username"]
password = form.cleaned_data ["password"]
User.objects.create_user (
username = 'username',
password = 'password'
)
user = authenticate (request,User)
else:
form = FormSito()
context = { form : 'form' }
# you had problem here
return render (request,"registration/form/registrazione.html", context)