Hello,
Please, i have a model form in forms.py which am trying to validate and
update my database with. However, for some reason the form is not being
validated. I have tried everything i could think of. It just reloads the
page.

views.py

> from django.shortcuts import render
> from information.forms import ContactForm
> from django.http import HttpResponse, HttpResponseRedirect
>
>
> def index(request):
>     form_class = ContactForm
>     if request.method == 'POST':
>         form = form_class()
>         if form.is_valid():
>             ###Dummy text to check validation
>             return  HttpResponse('Done')
>     return render(request, 'information/index.html', {'form': form_class})
>
>
> def complete(request):
>     return HttpResponse("Thank you for contacting us")
>
>
models.py


> from crispy_forms.helper import FormHelper
> from django import forms
> from django.core.exceptions import ValidationError
> from django.forms import Form
> from information.models import Contact
> from crispy_forms.helper import FormHelper
> from crispy_forms.layout import Layout,Fieldset, HTML
> from crispy_forms.bootstrap import TabHolder,Tab
>
>
> class ContactForm(forms.ModelForm):
>     helper = FormHelper()
>     helper.form_tag = False
>     def __init__(self):
>         super(ContactForm, self).__init__()
>         for key in self.fields:
>             self.fields[key].required= False
>             self.fields[key].label = False
>
>
>     class Meta:
>         fields = '__all__'
>         model =  Contact
>
>
Thank you.

-- 
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/CAE6v7oeD7Qb_%2BJrhiOzRTiDJ%3DqEPAY56B86nuxdZnrv2EP%2BrdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to