November 2015
Beginner to intermediate
840 pages
26h 30m
English
Tag Model name FieldRecall that in Chapter 3, we decided that our tag name field should all be lowercase because of database alphabetization. There is, at this point, nothing stopping a user from submitting a tag name in all caps. In the following subsection, we ensure that any string value submitted to our form will be submitted to the database in all lowercase.
In forms and models, field-specific clean methods come in the form of clean_<fieldname>(). We can create a custom clean method in our TagForm for the name field by implementing the clean_name() method. The goal of the clean method is to ensure that the value being passed is lowercase. In /organizer/forms.py, we code as shown in Example 7.13.
Example ...
Read now
Unlock full access