Closed bene25 closed 7 years ago
I don't understand your issue.
You should use {{ form.as_div }}
to have the expected behavior. Is that what you want?
Thanks for answer)) {{ form.as_div }} hides input field (EmailField) and there are only submit button left on page without errors and any other information.
Ok, let me describe my situation again:) I followed this doc http://django-angular.readthedocs.io/en/latest/angular-form-validation.html
And now I have form
class TestForm(NgFormValidationMixin, NgModelForm):
class Meta:
model = LightboxOrder
fields = ['lightbox_client_email']
labels = {
'lightbox_client_email': _('testemail'),
}
error_messages = {
'lightbox_client_email': {
'required': _("This writer's name is too long test."),
},
}
View:
class ContactFormView(TemplateView):
template_name = 'viveska/remont_reklamnoy_produkcii.html'
def get_context_data(self, **kwargs):
context = super(ContactFormView, self).get_context_data(**kwargs)
context.update(form=TestForm(auto_id=True))
return context
url:
url(r'^remont_reklamnoy_produkcii', ContactFormView.as_view(), name='remont_reklamnoy_produkcii'),
and remont_reklamnoy_produkcii.html:
{% extends 'viveska/base.html' %}
{% block page_content %}
<div class="container">
<form name="{{ form.form_name }}" novalidate>
{{ form.as_div }}
<input type="submit" value="Submit"/>
</form>
</div>
{% autoescape off %}{% endautoescape %}
{% endblock %}
firstly html was
<form name="{{ form.form_name }}" novalidate>
{{ form }}
<input type="submit" value="Submit"/>
</form>
and it looks like this. Submit button does nothing.
after I have changed to
<form name="{{ form.form_name }}" novalidate>
{{ form.as_div }}
<input type="submit" value="Submit"/>
</form>
it become looks like this. Submit button also does nothing .
Submit button does nothing because you have a novalidate tag in your form. It's because you're expected to handle the post call with angular itself, not django. try to add an ng-click tag with a function to handle your POST call. That's the whole point.
The as_div
is not what you were looking for. I did not read correctly your issue the first time. It's only used with the bootstrap styling (and mixin).
Cheers
reopen this ticket if you found a bug but I guess it was only a misunderstanding.
Hi there Django 1.10.5, python 3.5
I have form:
view:
url:
url(r'^test_validation', views.test_validation, name='test_validation'),
and hml template test_validation.html:
But form rendered with errors displayed as ul and invalid data input doesn't take affect on this messages. Any help. Thanks.