Often times applications will need some database code tables (aka reference tables or domain tables or lookup tables). Suppose I have a model class called Status with a field called name that could hold values like:
Canceled
Pending
InProgress
Complete
Where and at what point would I setup these values in Django? Its like a one time operation to setup these values in the database. Infrequently, these values could be added to.
And I guess more generically, how do you initialize models with data? For example, say I had a model for holding the make of a car and I want to initialize this list with a set of known values. How would I do this?
You'll want to use a fixture for that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With