is_valid() error when creating SignUpForm

Hello! I am creating a Sign Up form but for some reason my editor is showing that login(request, user) has to many positional arguments. When I ignore the error and try to sign up. I get this error. 'SignUpForm' object has no attribute 'is_vaild'
----
Here is my views.py:

from django.contrib.auth.decorators import login_required
from django.db.models import Q
from django.shortcuts import render, redirect

from product.models import Product, Product_Photo, Category
from .forms import SignUpForm

def home(request):
    products = Product.objects.all()[0:8]

    return render(request, "core/home.html", {"products": products})

**def signup(request):**
**    if request.method == 'POST':**
**        form = SignUpForm(request.POST)**

**        if form.is_vaild():**
**            user = form.save()**

**            login(request, user)**

**            return redirect('/')**
**    else:**
**        form = SignUpForm()**

**    return render(request, 'core/signup.html', {'form': form})**

def login(request):
    return render(request, 'core/login.html')

def shop(request):
    categories = Category.objects.all()
    products = Product.objects.all()

    active_category = request.GET.get('category', '')

    if active_category:
        products = products.filter(category__slug=active_category)

    query = request.GET.get('query', '')

    if query:
        products = products.filter(Q(name__icontains=query) | Q(description__icontains=query))

    context = {
        'categories': categories,
        'products': products,
        'active_category': active_category,
    }

    return render(request, 'core/shop.html', context)
type or paste code here

Here is my forms.py

from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User

class SignUpForm(UserCreationForm):
    first_name = forms.CharField(max_length=50, required=True)
    last_name = forms.CharField(max_length=50, required=True)
    email = forms.CharField(max_length=255, required=True)

    class Meta:
        model = User
        fields = '__all__'

I can’t seem to see what could be causing that error.

Notice the spelling error in the function name.

1 Like