[Django] #19727: form.is_valid() always returns false

18 views
Skip to first unread message

Django

unread,
Feb 3, 2013, 8:27:51 AM2/3/13
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------+--------------------
Reporter: Raul s | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Hello,

I'm getting crazy!

I created a form associated to a model. Everytime, when the
form.is_valid() function is executed on my views.py, django doesn't show
anything (it looks like if it works..) but actually it doesn't save
anything inside of the model.

The reason is that always form.is_valid() returns false.

Here my code:

models.py


{{{
from django.db import models

class Register(models.Model):
email = models.CharField(max_lenght=100)
}}}


forms.py


{{{
from django.form import ModelForm
from models.models import Register

class RegisterForm(ModelForm):
class Meta:
model = Register
}}}

views.py


{{{
from django.shortcuts import render_to_response
from models.models import Register
from register.forms import RegisterForm

def register(request):
if 'user_email' in request.POST:
form = RegisterForm(request.POST)
if form.is_valid():
form.save()
retunr render_to_response('registered.html')

return render_To_response('main.html')
}}}

PS_1: I show the value of the form in another page to check if it contains
just the e-mail and it's ok, it just contains the e-mail.

PS_2: request.POST contains 'user_email' sure.

Please, could you help me to solve it?

Thanks in advance.

--
Ticket URL: <https://code.djangoproject.com/ticket/19727>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 3, 2013, 8:49:21 AM2/3/13
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------+--------------------------------------

Reporter: Raul s | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.4
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by aaugustin):

* status: new => closed
* needs_docs: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

Please see TicketClosingReasons/UseSupportChannels.

Your form has an "email" field, not "user_email".

--
Ticket URL: <https://code.djangoproject.com/ticket/19727#comment:1>

Django

unread,
Feb 3, 2013, 9:45:28 AM2/3/13
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------+--------------------------------------

Reporter: Raul s | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.4
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by anonymous):

Thanks thanks thanks a lot.

It works!

Sorry for write down the issue in the wrong place.

Thanks again, thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/19727#comment:2>

Django

unread,
Feb 28, 2021, 9:30:15 AM2/28/21
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------+--------------------------------------

Reporter: Raul s | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.4
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Hussein Naim):

one more thing if you have an image field try to remove it and try again
for me it worked .
i don't know how to solve it but i remove the image filed and the form
sending

--
Ticket URL: <https://code.djangoproject.com/ticket/19727#comment:3>

Django

unread,
Feb 28, 2021, 9:33:28 AM2/28/21
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------------+-------------------------------------

Reporter: Raul s | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
django,form,model,formmodel |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hussein Naim):

* keywords: => django,form,model,formmodel
* status: closed => new
* type: Uncategorized => Bug
* resolution: invalid =>
* stage: Unreviewed => Accepted


Comment:

try to print the variable
```python
form.errors
```
and its will return to you the field that is not valid

--
Ticket URL: <https://code.djangoproject.com/ticket/19727#comment:4>

Django

unread,
Feb 28, 2021, 11:03:10 AM2/28/21
to django-...@googlegroups.com
#19727: form.is_valid() always returns false
-------------------------------------+-------------------------------------

Reporter: Raul s | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.4
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Accepted
django,form,model,formmodel |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed

* resolution: => invalid
* component: Uncategorized => Forms


--
Ticket URL: <https://code.djangoproject.com/ticket/19727#comment:5>

Reply all
Reply to author
Forward
0 new messages