Drop the html codes here please. Let one try it actually. It's difficult to
debug like this.

On Sat, Apr 20, 2019, 5:35 PM Sipum Mishra <[email protected]> wrote:

> Hi Vineeth,
>
> when I am trying to add 'add testing' through html form for todo list app
> getting this above form.is_valid() always False.
>
> On Sat, 20 Apr 2019 at 23:02, Sipum Mishra <[email protected]> wrote:
>
>> Hi Vineeth,
>>
>> please find below is the output ->
>>
>> <QueryDict: {'csrfmiddlewaretoken':
>> ['8V0Or1mvx2gtOa5fuYsdmAJ1o7SpGOcbSYulW0WMACHbrBhn8tOI0SO1z65MzXGx'],
>> 'Item': ['add tesing']}>
>>
>> On Fri, 19 Apr 2019 at 19:04, vineeth sagar <[email protected]>
>> wrote:
>>
>>> can you please post, request.POST output?
>>>
>>> On Fri, 19 Apr 2019, 16:34 Sipum Mishra, <[email protected]> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> 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 [email protected].
> To post to this group, send email to [email protected].
> 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/CAGHZBzwVAQOBoksQFVhUgBpC0bJyL4ZeahDHpKfxLpT6Z833TQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGHZBzwVAQOBoksQFVhUgBpC0bJyL4ZeahDHpKfxLpT6Z833TQ%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 [email protected].
To post to this group, send email to [email protected].
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/CAC26BE36LumBC4uGcwJDFNBX-wOyBzjH57uKY9dxQ_G0tGNbDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to