Generating the Development Data
Explore how to define data models and generate safe, realistic development data using standard tools like Faker and model_bakery. This lesson helps you populate your Django admin interface with meaningful data for testing filters, bulk actions, and interface changes effectively.
Trying to build and test custom admin filters, bulk actions, and search interfaces on an empty database is frustrating. To accurately see the impact of our architectural changes, we need a robust, realistic dataset.
We will establish our underlying data models first, and then use industry-standard tools to generate a safe volume of development data so we can begin customizing the admin interface.
Defining the quiz data model
Our sample application is a simple quiz system composed of three models: Author, Question, and Choice. We define these models inside the sample_app/models.py file. We use modern Python f-strings for our string representations, completely avoiding legacy string formatting patterns.
Lines 9, 19, and 29: Implements the
__str__methods using ...