Error : AttributeError: 'BookForm' object has no attribute 'get'. im unable to debug the problem.please be helping out.thanks in advance
forms.py
from django import forms
from .models import Book
class BookForm(forms.Form):
class Meta:
model = Book
fields = ['title', 'sub_title', 'author', 'image', 'price', 'description', 'ISBN', 'number_of_pages','dimensions', 'interior_pages','binding','availability','genre']
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('',views.BookForm, name = 'bookform' ),
]
views.py
from django.shortcuts import render,redirect from .forms import BookForm
def bookview(request):
if request.method == 'POST':
form = BookForm(request.post)
if form.is_valid():
model_instance = form.save()
model_instance.save()
return redirect('/')
else:
form = BookForm()
return render(request,'book.html',{'myform':form})
template
<html>
<head>
<title>edit</title>
</head>
<body>
<form method="post" >
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="ok">
</form>
</body>
</html>