Django: Setting up database code tables (aka reference tables, domain tables)?

1.8k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

You'll want to use a fixture for that.