Customizing the admin add and change survey pages
We've already seen how the Django admin application provides a convenient way to examine and manipulate data in our database. In the previous chapter, we set up the admin with some simple customizations to allow editing Questions
inline with Surveys
and Answers
inline with Questions
. Besides those inline customizations, however, we made no changes to the admin defaults.
One additional change that would be good to make to the admin is to ensure that Survey opens
and closes
dates are valid. Clearly for this application, it makes no sense to have an opens
date that is later than closes
, but there is no way for the admin to know that. In this section, we will customize the admin to enforce our application requirement on the relationship between opens
and closes
. We will also develop a test for this customization.
Developing a custom survey form
The first step in implementing this admin customization is to implement a form for Survey
that includes...