postgres.forms.SimpleArrayField.base_field

base_field

This is a required argument.

It specifies the underlying form field for the array. This is not used to render any HTML, but it is used to process the submitted data and validate it. For example:

>>> from django.contrib.postgres.forms import SimpleArrayField
>>> from django import forms

>>> class NumberListForm(forms.Form):
...     numbers = SimpleArrayField(forms.IntegerField())

>>> form = NumberListForm({'numbers': '1,2,3'})
>>> form.is_valid()
True
>>> form.cleaned_data
{'numbers': [1, 2, 3]}

>>> form = NumberListForm({'numbers': '1,2,a'})
>>> form.is_valid()
False
doc_Django
2016-10-09 18:39:21
Comments
Leave a Comment

Please login to continue.