from .forms import CommentForm
def about(request):
title = "ola"
#title = "Hello Stranger"
#if request.user.is_authenticated():
# title = "Welcome Member %s" %{request.user}
user = request.user
form = CommentForm(request.POST or None)
context = {'user': user,
'title': title,
'form': form
}
if form.is_valid():
form.save()
#instance = form.save()
#if not instance.name:
# instance.name = "robert"
#instance.save()
context = {
"title": "Thanks"
}
templates = 'about.html'
return render(request, templates, context)
Form code :
from django import forms
from .models import Comment
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ["name", "email", "comment"]
def clean_email(self):
email = self.cleaned_data.get("email") email_base,
provider = email.split("@") domain,
extension = provider.split('.')
#if not "hotmail" in email:
# raise forms.ValidationError("Please do hotmail")
return email
def clean_name(self):
name = self.cleaned_data.get("name")
return name
I'm getting this error: AttributeError at /about/ 'CommentForm' object has no attribute 'save' Request Method: POST What I want is to see the responses from the users , meaning there data once they fill out the comment form but i get this error and do not see any of the comments in the django/admin. any help would be great thanks