November 2015
Beginner to intermediate
840 pages
26h 30m
English
TagForm in the Django ShellTo demonstrate the use of TagForm, including the validation and binding data to the form, we can turn to the Django shell (available from your terminal with ./manage shell). In Example 7.4, we invoke the shell, import TagForm, and instantiate the class.
Example 7.4: Python Interpreter Code
>>> from organizer.forms import TagForm >>> tform = TagForm()
As with models, the inheritance of forms.Form affords us all of the behavior Django expects forms to have. Notably, we can see if the form has been given data thanks to the is_bound data attribute, and we can check whether this data has been correctly validated and cleaned thanks to the is_valid() method, shown in Example 7.5 ...
Read now
Unlock full access