I am trying to save the data in database using Python-Django. But i am getting this error:
'userInfo' object has no attribute 'suggestion' This is my model.py file model.py
class userInfo(models.Model): #user = models.ForeignKey(User) #age = models.IntegerField() u_name=models.TextField("Name", null = True, blank = True) u_address=models.TextField("Address", null = True, blank = True) def __unicode__(self): return self.u_name This is my view.py file
view.py
def gaurav(request): print request form=userInfoForm() if request.POST: form = userInfoForm(request.POST) anw=form.save(commit=False) anw.user=request.user anw.save() form= userInfoForm(request.POST) if form.is_valid(): user1=form.save() return render(request, 'userview/home.html', {'form': form}) This is my form.py file
form.py
class userInfoForm(forms.ModelForm): class Meta: model = userInfo def __init__(self, *args, **kwargs): super(userInfoForm,self).__init__()