Opened 12 years ago
Closed 4 years ago
#19727 closed Bug (invalid)
form.is_valid() always returns false
Reported by: | Raul s | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.4 |
Severity: | Normal | Keywords: | django, form, model, formmodel |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Change History (5)
follow-up: 3 comment:1 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 12 years ago
Thanks thanks thanks a lot.
It works!
Sorry for write down the issue in the wrong place.
Thanks again, thanks.
comment:3 by , 4 years ago
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
comment:4 by , 4 years ago
Keywords: | django form model formmodel added |
---|---|
Resolution: | invalid |
Status: | closed → new |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
try to print the variable
`python
form.errors
`
and its will return to you the field that is not valid
comment:5 by , 4 years ago
Component: | Uncategorized → Forms |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Please see TicketClosingReasons/UseSupportChannels.
Your form has an "email" field, not "user_email".