Hi Vineeth, please find below is the output ->
<QueryDict: {'csrfmiddlewaretoken': ['8V0Or1mvx2gtOa5fuYsdmAJ1o7SpGOcbSYulW0WMACHbrBhn8tOI0SO1z65MzXGx'], 'Item': ['add tesing']}> On Fri, 19 Apr 2019 at 19:04, vineeth sagar <vineeth.saga...@gmail.com> wrote: > can you please post, request.POST output? > > On Fri, 19 Apr 2019, 16:34 Sipum Mishra, <sipu...@gmail.com> wrote: > >> Hi All, >> >> I am always getting - form.is_valid returning False. kindly check where I >> am doing wrong. >> please find below code. >> >> >> views.py >> ----------- >> def home(request): >> >> if request.method == 'POST': >> form = ListForm(request.POST or None) >> print(form.is_valid(), "-->",request.POST['Item']) >> print(form.errors) >> print(form) >> if form.is_valid(): >> form.save() >> all_items = List.objects.all >> messages.success(request, ('Item has been Added to the List!')) >> return render(request,'home.html', {'all_items' : all_items}) >> else: >> print("deba-->",request.POST) >> return HttpResponse("Form is invalid!") >> else: >> all_items = List.objects.all >> return render(request,'home.html', {'all_items' : all_items}) >> >> ------------- >> form.py >> ------------- >> >> class ListForm(forms.ModelForm): >> class Meta: >> model = List >> fields = ["item", "completed"] >> >> >> -------------------- >> model.py >> --------------------- >> >> class List(models.Model): >> item = models.CharField(max_length=200) >> completed = models.BooleanField(default=False) >> >> >> def __str__(self): >> return self.item + '|' + str(self.completed) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/4ca5e82d-f34b-4ab4-8f82-5be0dcdebecc%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAMMZq8OxVOJ8cF%3DFTNriHjBXKvdv29in-gOB-M-ia86L_ntSQw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGHZBzxon22bfLUUud8tMFxyxQ36bJxZKu2yhvObPMFwbQmVpQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.