mardi 31 janvier 2017

unknown error -django 1.8 checkbox widget/boolean field

In modal there is a field

anonymous = models.BooleanField(default=True)

This a form:

class QuestionForm(forms.ModelForm):
question = forms.CharField(required=True, label='', max_length=5000, widget=forms.widgets.Textarea(attrs={'class': 'question_textarea','placeholder':'Write your question here'}))
anonymous = forms.BooleanField(initial=True, widget=forms.widgets.CheckboxInput(attrs={'class': 'anonymous_checkbox'}))
class Meta:
        model = Question
        fields = ('question','anonymous',)

When anonymous field is selected in html(as default) the form works, but otherwise I get unknown error:

{"error":{"type":"http","message":"unknown error"}}

What am I doing wrong and how to fix?




Aucun commentaire:

Enregistrer un commentaire