Django / Bootstrap RadioButton Rendered似乎被禁用

时间:2017-12-10 20:28:50

标签: django python-2.7 twitter-bootstrap-3 django-bootstrap3

我正在使用Django1.8.6和django-bootstrap3。这是我公司设置程序状态和隐私的模型

class CompanyInformationSetting(models.Model):
PROGRAM_PRIVACY = (
    ('private', 'Private'),
    ('public', 'Public')
)
PROGRAM_STATUS = (
    ('active', 'Active'),
    ('Inactive', 'Inactive')
)
program_privacy = models.CharField(max_length=30,
                                   choices=PROGRAM_PRIVACY,
                                   default='public')
program_status = models.CharField(max_length=30,
                                  choices=PROGRAM_STATUS,
                                  default='Inactive')
company_user = models.OneToOneField(User)
twitter_handle = models.URLField(max_length=250, blank=True)
blog_or_website_url = models.URLField(max_length=250, blank=True)
about_or_tagline = models.TextField(max_length=500, blank=True)

这是我正在使用的表单,以便用户可以相应地更改值。

class CompanyInformationSettingForm(forms.ModelForm):
program_privacy = forms.ChoiceField(choices=CompanyInformationSetting.PROGRAM_PRIVACY,
                                    widget=forms.RadioSelect())
program_status = forms.ChoiceField(choices=CompanyInformationSetting.PROGRAM_STATUS,
                                   widget=forms.RadioSelect())
twitter_handle = forms.URLField(max_length=250,
                                widget=forms.TextInput(attrs={'placeholder': 'www.twitter.com/123456'}
                                                       )
                                )
blog_or_website_url = forms.URLField(max_length=250,
                                     widget=forms.TextInput(attrs={'placeholder': 'www.example.com/123'}
                                                            )
                                     )
about_or_tagline = forms.CharField(max_length=100,
                                   widget=forms.TextInput(attrs={
                                       'placeholder': 'Give us your TagLine which tell us about you'
                                   }
                                                          )
                                   )

class Meta:
    model = CompanyInformationSetting
    fields = ('program_privacy', 'program_status', 'twitter_handle',
              'blog_or_website_url', 'about_or_tagline')

使用像这样的django-bootstrap3模板标签在我的模板中渲染表单

<form class="" role="form" action="" method="post">
                                    {% csrf_token %}
                                    {% bootstrap_form company_information_setting_form %}
                                  <div class="row m-t-20 m-b-10">
                                    <div class="col-lg-12">
                                      <div class="pull-left">
                                        <button class="btn btn-complete" type="button" id="previous_policy">Previous Policy</button>
                                      </div>
                                      <div class="pull-right">
                                        {% buttons %}
                                        <button class="btn btn-complete" type="submit" >Save</button>
                                          {% endbuttons %}
</form>

然而,当我运行我的开发服务器时,呈现的表单显示放射性选择被禁用,因为我无法选择任何内容

任何人都可以建议在bootstrap3中使用radiobuttons渲染表单的更好方法。

输出模板的图像

enter image description here

我想我能够清楚地解释这个问题

0 个答案:

没有答案