Receiving error message "name 'SaveInput' is not defined" while defining a save method Django

I am trying to create a save method (.save()) for my forms.Form in Django views.py but I keep receiving an error message - name 'SaveInput' is not defined.

from django.shortcuts import render
from django.shortcuts import redirect
from django.urls import reverse
from django.http import HttpResponseRedirect
from django.http import HttpResponse
from django import forms
import markdown2

from . import util

class AddPageForm(forms.Form):
    title = forms.CharField(max_length=20)
    content = forms.CharField(widget=forms.Textarea(
        attrs={
            "class": "form-control",
            "placeholder": "Tell us more!"
        })
    )


def add_page(request):
    submitted = False
    if request.method == "POST":
        form = AddPageForm(request.POST)
        entries = util.list_entries()
        
        if form.is_valid():
            title = form.cleaned_data['title']
            content = form.cleaned_data['content']
            saveInput = SaveInput(title=data['title'], content=data['content'])
            saveInput.save()
            
            for entry in entries:
                if title.upper() == entry.upper():
                    context = {
                        "title": title,
                        "content": content
                    }
                    return render(request, "encyclopedia/errorpage.html", context)
            else:
                return HttpResponseRedirect(reverse("/encyclopedia:index/?submitted=True"))
    else:
        return render (request, "encyclopedia/addpage.html", {
            "form": AddPageForm()
        })

    Traceback Switch to copy-and-paste view
C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py, line 47, in inner
                response = get_response(request) …
▶ Local vars
C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\base.py, line 181, in _get_response
                response = wrapped_callback(request, *callback_args, **callback_kwargs) …
▶ Local vars
C:\Users\USER\Downloads\wiki\wiki\encyclopedia\views.py, line 84, in add_page
            saveInput = SaveInput(title=data['title'], content=data['content']) …
▶ Local vars

Kindly tell me what I am doing wrong as the examples I have seen previously regarding the same save method did not require to define this.

Also, how do make sure that no page can be created if there is previously an added page with the same title without models .filter.

Thank you.

You need to either import or define SaveInput in your views.py

Back to Top