I'm a django learner and I was trying to create user registration form using the in-build UserCreationForm
.
view.py
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_vaild():
username = form.cleaned_data['username']
return redirect('blog-home')
else:
form = UserCreationForm()
return render(request, 'users/register.html',{'form':form})
While trying to POST
i'm receiving 'UserCreationForm' object has no attribute 'is_vaild'
. If i understand correctly for all the django forms there will be a is_valid function to validate.
Please help me to find what am i missing here.
Let me know if you need any other file details.
I'm using Django 2.1,Python 3.6
Please take in mind that you still need to send something in case the form is invalid !form.is_valid() added a few lines to your code, BTW your simply mispelled is_valid()