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 disabled ( https://github.com/django/django/blob/1.10.6/django/forms/forms.py#L379)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8e2ebc95-8d9d-46ad-857f-db8b2b23e0e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment