4π
If form is not getting saved when you perform a check of form.is_valid()
means the form was invalid. In such cases, we should display the errors found by the form for every field. For that to happen, first you should pass form data to templates, if form is invalid.
#views.py
def orcamento(request):
form = OrcamentoForm(request.POST or None, request.FILES or None)
if request.method == 'POST':
if form.is_valid():
form.save()
return render_to_response("webSite/teste.html", context_instance = RequestContext(request))
#Following will run in all cases except when form was valid
return render_to_response("webSite/orcamento.html", {"form": form }, context_instance=RequestContext(request))
You can display all the errors thrown by the form or field-wise errors in your template. See the django documentation detailed understanding.
0π
The same error occurred when I mistyped
.is_valid()
as .is_valied()
.
You might wanna check whether itβs the case.
0π
This error can also occur if you never included the ()
in .is_valid()
. Having the validity checker as .is_valid:
also raises the same error.
- [Django]-Attach permissions and groups to custom User model created from BaseUserAdmin
- [Django]-How do I add a temporary field to a model in Django?
0π
This error happened to me but I solved by adding parentheses to is_valid and it became is_valid() and the error went and never come back
- [Django]-How to change model class name without losing data?
- [Django]-Create a custom html template using forms in Django
- [Django]-How to aggregate group in mongoengine python
- [Django]-How to join multiple params dynamically for django Q object
- [Django]-How do you add similar posts to a detail page using django