initial not work in Form Field

11 views
Skip to first unread message

郭城熙

unread,
Mar 11, 2017, 9:52:26 AM3/11/17
to Django users
Hello, I don't understand why initial not work in my code , here is it:

class QuestionListForm(forms.Form):
    _id = forms.IntegerField()
    page = forms.IntegerField(required=False, initial=12)



class MyView(View):
    def get(self, request):
        form = QuestionTypeForm(request.GET, initial={'page':12})

Then:
   I request with this url:   http://localhost:8000/apis/question_type?subject=21


But i cann't get any default value of 'page' field.

And I don't understand why initial work when this  field  is disabledhttps://github.com/django/django/blob/1.10.6/django/forms/forms.py#L379)
Reply all
Reply to author
Forward
0 new messages