Django forms which fields are required as "bound" fields to validate -


per question: difference between django form 'initial' , 'bound data'? :

here's key part django docs on bound , unbound forms.

if it’s bound set of data, it’s capable of validating data , rendering form html data displayed in html.

if it’s unbound, cannot validation (because there’s no data validate!), can still render blank form html.

my question is: there easy way know which fields need bound in order validate?

we have multi-inheritance modelform nightmare , it's tough figure out minimum required fields "bind".

in case i've tried matching form.data vars(form.fields), not enough, it's ongoing potluck tracking through models , adding more , more form.data in ad-hoc way.

is there cardinal list somewhere of minimum requirements of bindable fields?

based on clarifying comment:

[t]here data, form still form.is_bound=false. want know more need add data in order is_bound true.

it's not question of data present or absent, it's question of how construct form object.

from docs:

to create unbound form instance, instantiate class:  >>> f = contactform()  bind data form, pass data dictionary first parameter form class constructor: >>> data = {'subject': 'hello', ...         'message': 'hi there', ...         'sender': 'foo@example.com', ...         'cc_myself': true} >>> f = contactform(data) 

that is, if provided argument when instantiating form, it's bound. if not, not.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -