Radio button in form - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Radio button in form (/thread-23717.html) |
Radio button in form - Heinrich - Jan-14-2020 Hi, I have a small web app which simply takes input via a form and executes a http POST request with the values entered to API. this is my forms.py rom django import forms CHOICE = [('true', 'True'), ('false', 'False')] class FeatureFlagsForm(forms.Form): tenants_id = forms.CharField( label='Tenant ID', max_length=40, required=True, widget=forms.TextInput( attrs={ 'placeholder': 'Enter Tenant ID (GUID)', 'size': '50' }) ) is_allowed_to_access_staff = forms.ChoiceField(label='Tenant allowed to access staff?', choices=CHOICE, widget=forms.RadioSelect) is_allowed_to_access_compliance = forms.ChoiceField(label='Tenant allowed to access compliance?', choices=CHOICE, widget=forms.RadioSelect ) is_allowed_to_access_experts = forms.ChoiceField(label='Tenant allowed to access compliance?', choices=CHOICE, widget=forms.RadioSelect ) should_auto_provision_users = forms.ChoiceField(label='Auto-provision users?', choices=CHOICE, widget=forms.RadioSelect ) show_only_external_login = forms.ChoiceField(label='Show external login only?', choices=CHOICE, widget=forms.RadioSelect ) show_tc_compliance_message = forms.ChoiceField(label='Tenant allowed to access compliance?', choices=CHOICE, widget=forms.RadioSelect )my view: if form.is_valid(): tenants_id = form.cleaned_data.get('tenants_id') access_staff = form.cleaned_data.get('access_staff') access_compliance = form.cleaned_data.get('access_compliance') auto_provision_users = form.cleaned_data.get('auto_provision_users') show_ext_login = form.cleaned_data.get('show_ext_login')however when I print access_staff for example I get <class 'NoneType'> Why is the input from the form of type "NonceType" ??? RE: Radio button in form - Heinrich - Jan-14-2020 Dah! I found my silly mistake. variable in forms.py do not match variable names in view |