python - Models.py And Forms.py in django 1.11 -
i've created contact form, , want data on mysql database, not happening in case. i've built form in forms.py , should noted models.py file empty. don't know add on models.py file trigger changes database. here code forms.py
from django import forms class contactform(forms.form): options = (("aut", "austria"),("deu", "germany"),("nld", "neitherlands"),) subject=forms.charfield() email=forms.emailfield(required=false) message=forms.charfield(widget=forms.textarea) countries = forms.multiplechoicefield(widget=forms.checkboxselectmultiple,choices=options) def clean_message(self): message = self.cleaned_data['message'] num_words = len(message.split()) if num_words < 4: raise forms.validationerror("not enough words!") return message def clean_countries(self): countries=self.cleaned_data['countries'] if len(countries)==1: raise forms.validationerror("select atleast more 1") return countries please suggest changes need make in models.py.
ps: i've integrated mysql django, table user input not showing in database.
Comments
Post a Comment