Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Radio button in form
#1
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" ???
Quote
#2
Dah!

I found my silly mistake. variable in forms.py do not match variable names in view Smile Big Grin Big Grin Big Grin
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  form fill & button clicks rudolphyaber 3 573 Apr-25-2019, 06:32 PM
Last Post: Larz60+
  Submit button not working when using form tuannv562 0 1,396 Apr-23-2018, 03:49 AM
Last Post: tuannv562

Forum Jump:


Users browsing this thread: 1 Guest(s)