Why section of my django project views getting queryset error?

Hello I have a django project for calorie tracker and when I go to fooditem_create url I get this error :

FoodItemCreateView is missing a QuerySet. Define FoodItemCreateView.model, FoodItemCreateView.queryset, or override FoodItemCreateView.get_queryset().

this is my views:

from .forms import *
from django.urls import reverse_lazy
from .models import *
from accounts.models import CustomUser
from django.views import generic
from django.views.generic import ListView
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin



class FoodItemCreateView(LoginRequiredMixin, generic.CreateView):
    mode = Fooditem
    template_name = 'fooditem_create.html'
    fields = "__all__"
    success_url = reverse_lazy('fooditem_list.html')


class FoodItemListView(LoginRequiredMixin,ListView):
    model = Fooditem
    template_name = 'fooditem_list.html'
    fields = "__all__"

    
class FoodItemDeleteView(LoginRequiredMixin,generic.DeleteView):
    model = Fooditem
    template_name = 'fooditem_delete.html'
    success_url = reverse_lazy('fooditem_list.html')



@login_required(login_url='login')
def SelectFoodCreateView(request):
    usernow = CustomUser.objects.get(id=request.user.id)
    form = selectfoodForm(request.user, instance=usernow)

    if request.method == "POST":
        form = selectfoodForm(request.user, request.POST, instance=usernow)
        if form.is_valid():
            name = form.cleaned_data.get('name')
            category = form.cleaned_data.get('category')
            quantity = form.cleaned_data.get('quantity')
            person = form.cleaned_data.get('person')
            selectedfood = Selectfooditem.objects.create(
                name=name, quantity=quantity, category=category, person=person)
            selectedfood.save()
            return redirect('/manage/profile')
        else:
            form = selectfoodForm(request.user)
    context = {'form': form}
    return render(request, 'addfood_create.html', context)

@login_required(login_url='login')
def ProfileView(request):
    usernow = CustomUser.objects.get(id=request.user.id)
    calorielimit = usernow.calorielimit
    selectedfood = Selectfooditem.objects.filter(person=request.user)
    calorieconsumed = 0
    calorieleft = calorielimit

    for food in selectedfood :
        calorieconsumed+= (food.name.calorie * food.quantity)
        calorieleft = calorielimit - calorieconsumed

    
    context = { 'Food selected by {user}':selectedfood ,'Calorielimit':calorielimit , 'Calorieconsumed': calorieconsumed , 'calorieleft' : calorieleft}

    return render(request, 'profile.html', context)
    

class DeleteFoodView(LoginRequiredMixin,generic.DeleteView):
    model = Selectfooditem
    template_name = 'deletefoodview_delete.html'
    success_url = reverse_lazy('profile')


@login_required(login_url='login')
def EditCalorielimitView(request):
    if request.method == 'POST':
        user = CustomUser.objects.get(id=request.user.id)
        user.calorielimit = request.POST.get('calorielimit')
        user.save()
        return redirect('manage/profile')

    return render(request, 'calorielimit_edit.html')

my html template:

{% extends 'base.html' %}   
{% block content %}    
     <form action="" method="post">         
        {% csrf_token %}         
        {{ form.as_p }}         
            <button class="btn btn-success ml-2" type="submit">Save</button>     
     </form> 
{% endblock content %}>      

and my models:

from django.db import models
from accounts.models import CustomUser

class Fooditem(models.Model):
    name = models.CharField(max_length=200)
    calorie = models.PositiveIntegerField(default=0)
    carbs = models.FloatField(default=0,null=True,blank=True)
    protein = models.FloatField(default=0,null=True,blank=True)
    fat = models.FloatField(default=0,null=True,blank=True)
    person = models.ForeignKey(CustomUser,on_delete=models.CASCADE)

    def __str__(self):
        return str('{name} ({cal} calorie)'.format(name=self.name, cal=self.calorie))


class Selectfooditem(models.Model):
    option=(
        ('breakfast','breakfast'),
        ('lunch','lunch'),
        ('dinner','dinner'),
        ('snacks','snacks'),
    )
    name=models.ForeignKey(Fooditem,on_delete=models.CASCADE)
    category=models.CharField(max_length=50,choices=option)
    quantity = models.PositiveIntegerField(default=1)
    person = models.ForeignKey(CustomUser,on_delete=models.CASCADE)

I searched for the error and I think this error is for listview not for createview

its just a typo

class FoodItemCreateView(LoginRequiredMixin, generic.CreateView):
    mode = Fooditem

mode should be model=...

Back to Top