Changing How Models Are Edited
Changing How Models Are Edited. You can customize more than just the change list page. The screens used to add or change an object are based on a
ModelForm. Django automatically generates the form based on the model being edited.
Now, as you can see onscreen, when the Add or Change page is displayed, the label of the
first_name field is customized. Changing the label might not be sufficient to prevent vampires from registering as students.
This code enforces additional validation on the
Person Add and Change pages.
ModelForm objects have a rich validation mechanism. In this case, the
first_name field is being checked against the name
ValidationError prevents students with this name from registering.
02:38 With more control over the data that’s presented and how it’s edited and changed, the next area to investigate is changing the templates which control the appearance of the admin area pages, and that’s what you’ll be seeing in the next section.
Become a Member to join the conversation.