python - request.POST.get('<BooleanField>') always returns 'on' in Django (1.8) -


i'm trying extract data django form in view. i'm using request.post.get(). i'm aware form.cleaned_data[] preferred, can't use because incompatible ajax, need form (form.is_valid() returns false; if has way around this, that'd great too.)

anyways, form has few booleanfields:

distributive = forms.booleanfield(widget=forms.checkboxinput(attrs={'id':'distributive'}),required=false) transitivity = forms.booleanfield(widget=forms.checkboxinput(attrs={'id':'transitivity'}),required=false) 

whether these fields "checked" or not user, request.post.get() returning 'on'.

here code view:

def post(self, request):     form = verbqueryform(request.post)     transitivity = request.post.get('transitivity')     distributive = request.post.get('distributive') 

what i'm looking either:

a. (ideal, not point of post) way use form.is_valid() , cleaned_data ajax

b. way request.post.get() return boolean values

c. way request.post.get() consistently return strings 'true' , 'false' (or 2 strings), can work around problem using like:

transitivity = request.post.get('transitivity') == 'true' 

any appreciated. thanks!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -